-
Notifications
You must be signed in to change notification settings - Fork 113
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
Handle Sec-WebSocket-Protocol header #61
Comments
Right, I thought this was optional but it is actually required by the spec. I haven't done it yet because the need hasn't come up, and I'm a little bit short on time at this point due to work. It would be nice if you could put together a pull request! I don't mind giving a few implementation pointers.
Then, I would add an Do you agree with this? Do you need more information on anything? I'd be glad to help where necessary. |
I am experiencing timeouts after 5 minutes and I'm wondering if this might be the root cause. I patched yesod-websockets with the forkPingThread suggestions but some people still see the following in their logs intermittently:
Seems to be at least related to the Sec-WebSocket-Protocol header. |
Okay, the fix for this issue was fairly simple. I noticed that the "Sec-WebSocket-Protocol" header value from my browser was "Sec-WebSocket-Protocol". So, instead of conn <- acceptRequest pending I used, conn <- acceptRequestWith pending (AcceptRequest (Just "Sec-WebSocket-Protocol")) That fixed my issue entirely. Everything worked flawlessly after that. |
@wraith great, I'm testing that patch now. Was your problem related to the one I posted? |
I don't think so. I'm using websockets-snap, and I wasn't having problems with timeouts. I was having problems with the handshake, as stated in the first comment. |
It looks like the handshake code doesn't do anything with the Sec-WebSockets-Protocol header. When I try to connect to my websocket proof of concept server (https://gist.github.com/benkolera/9427813) with www.novnc.com I get an exception in the novnc javascript code:
Now looking into the headers I can see that novnc is trying to connect and establish with us to send things as binary or base64 (both of which we can do).
But when we respond with the websocket upgrade there is no mention of the protocol that we agree to use:
And I believe that it is required by the spec to do such a thing (https://tools.ietf.org/html/rfc6455#section-1.3)
Is this something that has been considered before and not done for a reason or has in not been done because of the lack of need or time? If it is the latter, I can do the work to get together a pull request that would make this happen. Without thinking about it too much or having too much experience with the code other than the code dive I just did, I had it in my head that we'd have to change pending request to have a list of protocols being requested and have the acceptRequest method choose a protocol (if there is a choice to be made) somehow.
The text was updated successfully, but these errors were encountered: