Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Header Behavior is breaking websocket upgrades in Firefox + socket.io #112

Open
LoaderB0T opened this issue Aug 23, 2021 · 0 comments

Comments

@LoaderB0T
Copy link

Hi there,

this issue is basically a copy of an issue in the original repo that does not get that much attention.

We're using socket.io for websocket connectivity and noticed that once our node module was being loaded up via iisnode, our Firefox clients started received 400 Bad Request when attempting to upgrade their connection from xhr polling to websockets.

The section in the code responsible for this, is suspected to be this one:
https://github.com/tjanczuk/iisnode/blob/bd95f4210c398bff8f8a3c68d031d03cff052512/src/iisnode/cprotocolbridge.cpp#L726

Firefox insists on sending keep-alive in the connection header, so a Firefox client's upgrade attempt will have a connection header set to keep-alive, Upgrade. Would it be possible to change the stricmp to a contains-style comparison, or forward the Connection header value on if already set? (I assume the former option is better than the latter since I'm guessing there's other behavior which requires keep-alive to be set for iisnode to work?)

There is also a PR in the original repo that aims to fix this issue.

And last but not least, there is a known workaround. We simply have to remove the "keep-alive" part of the connection header that gets added by Firefox.

To do so, you first have to add the HTTP_CONNECTION variable to the list of allowed variables in the URL REWRITE 2.0 Module in IIS and add a new rewrite rule in you web config:

<rule name="WebSocket remove keep-alive header" stopProcessing="true">
    <match url="(.*)socket\.io/" />
    <serverVariables>
        <set name="HTTP_CONNECTION" value="Upgrade" />
    </serverVariables>
    <action type="Rewrite" url="main.js" />
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_CONNECTION}" pattern="keep-alive, Upgrade" />
        <add input="{HTTP_CONNECTION}" pattern="Upgrade, keep-alive" />
    </conditions>
</rule>

The workaround works fine, but as Firefox does not seem to change its behavior, it would be great if this issue could be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant