kemalcr / kemal

Fast, Effective, Simple Web Framework
https://kemalcr.com
MIT License
3.61k stars 188 forks source link

Invalid Header (not a kemal error, just a heads-up) #312

Closed jasonl99 closed 7 years ago

jasonl99 commented 7 years ago

I was having a wierd problem with "invalid frame headers" using sockets. I finally narrowed it down after pulling my hair out for a few hours - it's the wifi at this particular location (coworking space). When I'm connected to that particular wifi, sockets don't work, and the javascript console shows

WebSocket connection to 'ws://<my domain>' failed: Invalid frame header

It happens in both Chrome and Firefox (though Firefox is not showing a socket error).

I fortunately had a few other (weaker) access points that are available, and on a hunch I connected to one of them, and suddenly I had no socket errors any more.

When connected with a "good" network, http://www.websocket.org/echo.html works. When connecting with the "bad" network, I get the following error in the javascript console:

WebSocket connection to 'ws://echo.websocket.org/?encoding=text' failed: Invalid frame header

This is clearly not a kemalcr issue, and some sort of network filtering, but I can imagine that people would pull their hair out trying to figure it out if they are not aware.

This document is I think the explanation. In short, unsecured ws:// connections will likely fail on a transparent proxy when the client attempts to send data, which is exactly when this error occurred in both cases. In the case of secure wss:// connections, there's a much better chance that the proxy will succeed.

So there's likely a transparent proxy that's not stripping the Connection: Upgrade header at on this access point. How common do you think this is?

jasonl99 commented 7 years ago

Just wanted to add a comment - I created an SSL certificate with letsencrypt, and now the websockets work fine.

sdogruyol commented 7 years ago

@jasonl99 that's great to hear 🎉