Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

websocket connection fails in Ubuntu 13.10

We're having a weird problem at work and I'm hoping someone here can give me some ideas on how to troubleshoot it.

The problem is that I cannot make websocket connections from my Kubuntu 13.10 workstation. I've tried from both Chrome and Firefox. I'm behind a proxy and first I thought that must be the reason. However, I got some coworkers to try to connect to the same websocket echo demo and all of them were able to, except one. He was the only one running Ubuntu (same as me), the others were on Mac, Windows and even one on RedHat! Theirs all worked fine.

Ok, so now for the really weird part. I created and ran a virtual machine on my workstation (the one that couldn't connect). The VM is a Lubuntu 13.10 and what do you know, the darn thing establishes a websocket connection just fine!

So any ideas on how to troubleshoot this or even some suggestions for solutions would be very much appreciated.

like image 248
StFS Avatar asked Mar 08 '14 23:03

StFS


People also ask

What causes a WebSocket to fail?

The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent for example).

Does WebSocket use port 80?

WebSocket is distinct from HTTP. Both protocols are located at layer 7 in the OSI model and depend on TCP at layer 4. Although they are different, RFC 6455 states that WebSocket "is designed to work over HTTP ports 443 and 80 as well as to support HTTP proxies and intermediaries", thus making it compatible with HTTP.


1 Answers

Ugh... well that one was dumb.

So it turns out that in Linux you can check a checkbox in your Network Proxy settings (the system settings) that will use the same proxy for all protocols.

Yeah... don't do that!

Unless, that is, your proxy server supports SOCKS as well as HTTP/HTTPS/FTP (highly unlikely).

It turns out that if you check that checkbox, your proxy server will be registered as a SOCKS proxy and for some reason, websocket connections in both Chrome and Firefox will want to use that. So your HTTP proxy will end up getting a bunch of weird SOCKS handshakes that it doesn't understand and any websocket connection will fail.

This was tested on both Ubuntu and Kubuntu and the "problem" exists on both.

TL;DR; Don't check the "Use this proxy server for all protocols" checkbox unless your proxy server supports the SOCKS protocol. Instead, manually fill in the same server for the different protocols (http, https and ftp) but leave the socks protocol empty (or point to an actual socks proxy server).

like image 68
StFS Avatar answered Oct 05 '22 17:10

StFS