Description of problem: The node ProxyServer seems to strip the Sec-WebSocket-Protocol header, which results in Python Autobahn WAMP not working. e.g. the following log is seen by the app: 2013-08-28 07:12:11-0400 [HTTPChannelHixie76Aware,113,127.2.229.129] received HTTP request: GET /ws HTTP/1.1 Connection: Upgrade Upgrade: websocket Sec-Websocket-Version: 13 Host: 127.2.229.129:8080 Sec-Websocket-Key: MTMtMTM3NzY4ODMzMTY1OA== 2013-08-28 07:12:11-0400 [HTTPChannelHixie76Aware,113,127.2.229.129] received HTTP status line in opening handshake : GET /ws HTTP/1.1 2013-08-28 07:12:11-0400 [HTTPChannelHixie76Aware,113,127.2.229.129] received HTTP headers in opening handshake : {'connection': u'Upgrade', 'upgrade': u'websocket', 'sec-websocket-version': u'13', 'host': u'127.2.229.129:8080', 'sec-websocket-key': u'MTMtMTM3NzY4ODMzMTY1OA=='} 2013-08-28 07:12:11-0400 [HTTPChannelHixie76Aware,113,127.2.229.129] Hybi protocol detected 2013-08-28 07:12:11-0400 [HTTPChannelHixie76Aware,113,127.2.229.129] failing WebSockets opening handshake ('this server only speaks WAMP') while the browser sent something like: Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language en-gb,en;q=0.5 Cache-Control no-cache Connection keep-alive, Upgrade Host broken-maschmid.rhcloud.com:8000 Origin http://broken-maschmid.rhcloud.com Pragma no-cache Sec-WebSocket-Key Af6M+OzGdk92dSu1bsZjCw== Sec-WebSocket-Protocol wamp Sec-WebSocket-Version 13 Upgrade websocket User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0 The workaround is to hack Autobahn to ignore the Sec-WebSocket-Protocol, so it doesn't fail with "this server only speaks WAMP". See also https://www.openshift.com/forums/openshift/websockets-with-nodejs https://www.openshift.com/forums/openshift/jetty-8xx-diy-cartridge-issues-with-websocket for people reporting the same problems. I believe the core of the problem might be in node-proxy/lib/proxy/ProxyServer.js where var proxy_ws = new WebSocket('ws://' + ws_endpoint + upg_requri, zheaders); doesn't pass the "protocol" attribute from the original request.
https://github.com/openshift/origin-server/pull/3612
Borrowing test case from the user reported issue on forum (https://www.openshift.com/forums/openshift/websockets-with-nodejs) - 1. Create a nodejs application. 2. Copy over server.js and package.json from https://github.com/jasonish/openshift-node-websocket 3. Modify server.js to use OPENSHIFT_NODEJS_IP instead of OPENSHIFT_INTERNAL_IP (same for PORT). 4. git push your changes. 5. Use the client.js from https://github.com/jasonish/openshift-node-websocket to test the server node client.js ws://app-ns.dev.rhcloud.com:8000/ 6. Verify the client keeps on getting data till it is stopped. (Without the fix, the client connection is immediately closed as the server expects to see Sec-Websocket-Protocol as "echo-server".
Tested on devenv_3776 with steps in comment#2, The connection will closed immediately. \> node client.js ws://no1-bmengdev.dev.rhcloud.com:8000/ Warning: Native modules not compiled. XOR performance will be degraded. Warning: Native modules not compiled. UTF-8 validation disabled. Connecting to ws://no1-bmengdev.dev.rhcloud.com:8000/ WebSocket client connected echo-protocol Connection Closed
Created attachment 796953 [details] Package.json file for testing.
Created attachment 796954 [details] Server.js file for testing.
I just retested and it worked for me. I have attached the package.json and server.js file that I used for testing this. (Ignore the native code compilation error for websocket module that doesn't affect this test case.). Also, to debug make sure the server is running after the push by tailing the ~/nodejs/logs/node.log
Check on devenv-stage_471, it works well now. And maybe the last time I failed because I am connecting the server inside the app gear. # node client.js ws://no81-bmengdev.dev.rhcloud.com:8000/ Connecting to ws://no81-bmengdev.dev.rhcloud.com:8000/ WebSocket client connected Received: '739888' Received: '15523852' Received: '16017545' Received: '3351055' Received: '4459250' Received: '2018313' Received: '4521020' Received: '3021884' Received: '14880327' Received: '9231157' Received: '4399874' Received: '4083156' Received: '8176787' Received: '6908197' Received: '11015009' Received: '15859325' Received: '771345' Received: '11924669' Received: '16454520' Received: '15474892' Received: '8429852' Received: '2977346' Received: '12174073' Received: '12879463' Received: '4589779' Received: '3582465' Received: '3438632' Received: '10037830' Received: '10095069' Received: '15920846'