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

No longer working on Chome 34.0.1847.76 #124

Closed
davidgiven opened this issue Mar 29, 2014 · 7 comments
Closed

No longer working on Chome 34.0.1847.76 #124

davidgiven opened this issue Mar 29, 2014 · 7 comments

Comments

@davidgiven
Copy link

After updating my app (which I haven't touched for a while) to work with the new APIs, I now find that while it still works fine on Firefox, trying to connect via Chrome 34 produces a 'Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received' message.

This is with ws4py 0.3.2-1 from Debian.

I have an instance of my app running --- I'll try to keep it going for a while. When it loads, you'll get a login page if everything's working or a 'Disconnected from server' if it's not.

http://cowlark.com/~dg/thickishstring

The source is browsable here:

https://cowlark.com/thickishstring/artifact/80406f2ca2a7c2ecebfd00ead64bf074b8b9c746

@Lawouach
Copy link
Owner

Hi, could you review #108 please? I think it relates to what you experience.

@davidgiven
Copy link
Author

I think #108 is related but different.

Examining the TCP stream I see this for Chrome:

GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: cowlark.com:8086
Origin: http://cowlark.com
Sec-WebSocket-Protocol: binary
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: dzzQZIWJW69ExZIChiEUTA==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)     Chrome/34.0.1847.76 Safari/537.36

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-Websocket-Version: 13
Sec-Websocket-Accept: hmKMG9KnUqZOWXT8Cj+kXndYMjY=
Date: Sun, 30 Mar 2014 10:53:45 GMT
Content-Length: 0

Firefox's is almost identical:

GET / HTTP/1.1
Host: cowlark.com:8086
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 Iceweasel/19.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: http://cowlark.com
Sec-WebSocket-Protocol: binary
Sec-WebSocket-Key: 5VrbF7sIwbluXQ+8dJqTkw==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-Websocket-Version: 13
Sec-Websocket-Accept: Eb1naQ9br8EtWpWMTH+qDP0JY1o=
Date: Sun, 30 Mar 2014 10:56:25 GMT
Content-Length: 0
<followed by handshake>

The error is being produced by this file in Chrome: https://chromium.googlesource.com/chromium/src/net/+/master/websockets/websocket_basic_handshake_stream.cc

I'm not sure I'm quite following the logic in that source file, but shouldn't the reply contain a Sec-WebSocket-Protocol header to tell the client which subprotocol the server's decided to use?

@Lawouach
Copy link
Owner

Yes. But what did you initialize the server handler with? Did you pass any subprotocols?

@davidgiven
Copy link
Author

I wasn't aware I could --- I can't find anything in the docs about subprotocols. I'm using the gevent backend, and my code is:

server = WSGIServer(
    ('0.0.0.0', args.port),
    WebSocketWSGIApplication(handler_cls=Connection)
)

How would I pass in a list of subprotocols?

@Lawouach
Copy link
Owner

The doc isn't always good I admit.

server = WSGIServer(
    ('0.0.0.0', args.port),
    WebSocketWSGIApplication(protocols=['chat'], handler_cls=Connection)
)

@davidgiven
Copy link
Author

Using a subprotocol of 'binary' makes everything work. Thanks!

@Lawouach
Copy link
Owner

Sweet. I will try to update the doc soon on this issue.

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

2 participants