Description of problem: Application does not support websocket after disabling xml pooling Version-Release number of selected component (if applicable): On fork_ami_US3054_323 How reproducible: Always Steps to Reproduce: 1. Create a nodejs application and embed mongodb-2.2 2. Follow https://github.com/ramr/pacman to setup application, using the dev/websockets branch rhc app create ns nodejs-0.6 rhc cartridge add mongodb-2.2 -a ns cd ns git remote add upstream -t dev/websockets git://github.com/ramr/pacman.git git pull -s recursive -X theirs upstream dev/websockets modify server.js, disable "xhr-polling" in line #128, in this case, if websocket fails, the app won't function well git push 3. Access app Actual results: Only the frame image is displayed, other images are not displayed, and I can not interact with this app via websocket Expected results: Should be functioning well without xml http request polling considering websocket is supported Additional info: This application will switch to xhr-polling if websocket failed, so this is the reason I disable "xhr-polling", under this situation, the application can only function well when websocket works well, and I can know websocket is supported as expected.
For websocket supported applications, I guess users intend to create a websocket server application that will communicate with the websocket client. In this situation, the server needs to find a port to bind to. $OPENSHIFT_INTERNAL_IP is 8080, and this is the port is used by our web application, so if I try to bind to this port, I will most likely get "address already in use" error. So I tried to bind a larger port, eg: 15001, after this, my websocket server starts well. Problem I have encountered is my client does not seem to connect to it successfully via ws://n2-us3054t6.dev.rhcloud.com:8000/ My client is not a web browser, but a ruby client tool I used in terminal. So my question is: 1. Can I bind to 15001 if I intend to develop my own websocket server 2. Should I only send websocket requests from browser instead of some ruby clients from terminal? Thanks!
What sort of an application is it? What's binding to port 8080 -- your app server? Web sockets works over http[s], so the client would first need to negotiate an HTTP protocol based request and then upgrade to websockets. 8080 is the only application server port we currently expose out to talk HTTP. This is the case when you create a normal web application. So what your 'app' and so the app server needs to do is take an HTTP request -- handle the protocol upgrade to web sockets and switch that connection/request to be handled as a web socket request. Both HTTP and WS work on port 8080 on the backend. Now on the frontend side, which is how we route requests to $OPENSHIFT_INTERNAL_IP:8080 we only handle and route WS requests via the new proxy server running on port 8000/8443 (not the 80/443 version which is just apache). As re: your questions: 1. We don't support any port for handling web traffic -- has to be 8080. This is sorta similar to a normal web application written say in python ... if you bind to 15000, we don't route to that port -- we always route to 8080. So you'd need to either use port 8080 on the gear or then you'd have to have an app server running on 8080, and then route to your custom port via on some routing scheme e.g. /abc15000/* uri would go to the server on port 15000 via port 8080 on the gear. 2. So what's the errors here? Maybe its something w/ the tool -- you can try using a utility called "wscat" which is already on the devenv to do testing. That works for me. Also what does the app + ruby client do? The simplest test would be to use an websocket echo server -- see attached sample. Steps to use it: 1. rhc app create -l rr65 -p'' -a wsecho -t nodejs-0.6 2. add 'ws' as a dependency to package.json "dependencies": { "ws": "*" }, 3. cp over the attached server.js (as server.js for the app) 4. git add + commit + push 5. You can then test it w/ the wscat utility on the devenv (or locally if you install the 'ws' nodejs module) as follows: wscat -c $uri -- uri should be the app's url on port 8000 sh$ wscat -c http://wsecho-rr65.dev.rhcloud.com:8000/ connected (press CTRL+C to quit) < websocket server app: hello from wsapp > yo < OpenShift-WSEcho: yo > wassup? < OpenShift-WSEcho: wassup?
Created attachment 659086 [details] server.js for Websocket Echo
Verified on devenv_2564 Steps: 1. Create nodejs application, embed mongodb-2.2 rhc app create pacman nodejs-0.6 rhc cartridge add mongodb-2.2 -a pacman 2. Deploy quickstart to this app cd pacman git remote add upstream git://github.com/ramr/pacman.git git pull -s recursive -X theirs upstream dev/websockets 3. Push changes to remote git push 4. Visit website via 8000 port, and check logs # tail -f /var/log/node-web-proxy/* Result: App is working well websocket traffics are logged: <-------------snippet-------------> 1354847697589:DEBUG:[Thu Dec 06 2012 21:34:57 GMT-0500 (EST)] - Handling HTTP[S] request to pacman-2564t.dev.rhcloud.com 1354847697589:DEBUG:[Thu Dec 06 2012 21:34:57 GMT-0500 (EST)] - Sending a proxy request to 127.0.250.129,8080 <-------------end-------------> The example from comment 2 also works well, Thanks! [root@domU-12-31-39-00-E2-C1 ~]# wscat -c http://wsecho-2564t.dev.rhcloud.com:8000/ connected (press CTRL+C to quit) < websocket server app: hello from wsapp > hi < OpenShift-WSEcho: hi > echo < OpenShift-WSEcho: echo