Websocket support


#1

Hello, I’ve been able to start my account and get things cloned and compiled, but I’m having a little trouble getting websocket access to work.

There doesn’t seem to be a ton of documentation about how the proxies from ports 8080-8082 work, or at least I can’t find it.

I’m running apache to serve main files on port 8080
I have a kind of admin/reporting httpd tool as a module in my server at 8081
Another module is websockets, listening on 8082

if I run ‘nc -lk 8082’ I can see when websocket connection attempts are being made, so I know that incoming routing is working.

But when I run the websocket server, the outgoing responses don’t get back to my socket and therefore the handshake never completes.

There was a mention here: Node.js websocket server on private workspace that maybe it’s because my workspace is set to private?

I also tried using apache’s proxy_wptunnel, which shows that apache proxies over to the websocket server and a tcp connection is made… however response data doesn’t get back to the socket and after 20 seconds the handshake times out.

Do I need to set a preference somewhere?

Also I notice that all the incoming websocket headers (like “Connection: Upgrade”) are being recapitalized by the C9 proxy. That probably doesn’t matter but it does show that incoming requests are being rewritten, and a few headers are added:

x-forwarded-proto: http
x-forwarded-port: 80
x-forwarded-for: 127.0.0.1

Anyone have an idea?


#2

For anyone interested, I think I found a solution.

The websocket server I’ve written is in Qt 5.8

I’ve filed a bug with Qt:
https://bugreports.qt.io/browse/QTBUG-59230

It seems that cloud9 or some step in the chain is inserting an empty cookie header, which the Qt implementation doesn’t like.

I’ve had to use proxy_wstunnel to strip that header, and now it connects!


#3

also, for anyone else doing this, it appears that the c9 proxy system will timeout after 30 seconds of inactivity, so you may have to implement qwebsocket::ping() if you’re going this route.