rabbitmq / rabbitmq-web-stomp

Provides support for STOMP over WebSockets
Other
89 stars 26 forks source link

Missing header Sec-WebSocket-Protocol during handshake #53

Closed JSteunou closed 8 years ago

JSteunou commented 8 years ago

It only happens when using new native websocket endpoint with Chrome which is stricter than Firefox (dont know who is right and dont know about the other browsers)

WebSocket connection to 'ws://localhost:15674/ws' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received

Using RMQ 3.6.1 chrome 49 firefox 45

essen commented 8 years ago

That's weird, that header is for selecting protocols implemented on top of Websocket. Browsers aren't supposed to set it on their own. I'll look into it.

JSteunou commented 8 years ago

It does not set it, Chrome complains about the header is missing in the response. Sorry if I explained it poorly. To sum it up:

JSteunou commented 8 years ago

more intel: if I do not set sec-websocket-protocol in the request, still nothing in the response but at least Chrome does not complain about inconsistency and it works.

essen commented 8 years ago

Yes I understood. Basically the way this header works is that if it's no set in the request, the server doesn't send it in the response; and if it's set in the request, the server must send it in the response with the selected protocol (and otherwise the connection fails). So Chrome is correct in failing.

Wondering why you set this header in the request though? Do we have something in RabbitMQ that says it's needed? We could select the first protocol in the request's header to make it work but it is meaningless if we don't follow that protocol.

JSteunou commented 8 years ago

https://github.com/jmesnil/stomp-websocket set protocols by default. It's a good practice, I would prefer the server check if one on the list match one in its list and send back the best match. Maybe not the first, but the upper version of the protocol.

And if you are not sure about sending it back because you might not follow the protocol, maybe that's another issue ;)

essen commented 8 years ago

I'm fine with improving the protocol header handling. I'll need to check what other clients are sending. Thanks for the feedback!

JSteunou commented 8 years ago

Thank you!

essen commented 8 years ago

I have pushed a fix for this (see PRs above). Please try and report! :-)

We explicitly support v12.stomp, v11.stomp and v10.stomp, as those three are registered at IANA.

michaelklishin commented 8 years ago

@essen this issue is for 3.6.x but both PRs are submitted against master.

essen commented 8 years ago

Sorry, looks like I make that mistake often...

essen commented 8 years ago

Done.

michaelklishin commented 8 years ago

@JSteunou email me at michael in RabbitMQ domain and let me know what package type you need for testing. I'll send one over.

JSteunou commented 8 years ago

thank you, will do that!

JSteunou commented 8 years ago

@essen tested, approved ;) @michaelklishin had a little warning about socat package not being installed, except that all went fine

Thank you both, great job!

michaelklishin commented 8 years ago

@JSteunou we are aware that installing with dpkg will emit a warning. socat is not essential to RabbitMQ operation.

Thanks for the update.

essen commented 8 years ago

Thanks!

lreisoliveira commented 8 years ago

Chrome or Firefox not work

Client from here: https://raw.github.com/jmesnil/stomp-websocket/master/lib/stomp.min.js

Stomp.client('ws://localhost:3000/websocket', ['v10.stomp', 'v11.stomp', 'v12.stomp']);

The response

WebSocket connection to 'ws://localhost:3000/websocket' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received

Why?

JSteunou commented 8 years ago

Are you using the latest RMQ?

michaelklishin commented 8 years ago

@lreisoliveira please post questions to rabbitmq-users or Stack Overflow. RabbitMQ uses GitHub issues for specific actionable items engineers can work on, not questions. This specific issue was fixed in the 3.6.2 release cycle as the milestone suggests. Thank you.

lreisoliveira commented 8 years ago

Thanks