Question

I'm testing my Node.js app that uses WebSockets on Heroku and I keep running into this error:

Client: WebSocket connection to 'ws://myapp.herokuapp.com/' failed: Error during WebSocket handshake: Unexpected response code: 503

Server: 2014-05-11T23:57:15.710087+00:00 heroku[router]: at=error code=H23 desc="Endpoint misconfigured" method=GET path=/ host=myapp.herokuapp.com request_id=a874df22-4a1a-44fb-bcc5-2473bf1e6370 fwd="151.35.127.210" dyno= connect= service= status=503 bytes=

I have Heroku labs websockets enabled and the program uses process.env.PORT.

EDIT: I tried deleting the app and recreating it using a different name, and now I'm getting this error:

Client: WebSocket connection to 'ws://myapp2.herokuapp.com/' failed: Error during WebSocket handshake: 'Connection' header value is not 'Upgrade': Upgrade

Server: 2014-05-13T23:27:52.443504+00:00 heroku[router]: at=info method=GET path=/ host=myapp2.herokuapp.com request_id=c83b94a6-04ef-42cf-9837-c4bda8a85c14 fwd="151.35.127.210" dyno=web.1 connect=26 service=1029 status=101 bytes=681

Does anyone know what could be causing this?

Thanks in advance.

Was it helpful?

Solution

After 5 days of chatting with Heroku support, I've solved the problem. Kind of. Heroku websockets just weren't working. I tried everything. So I finally decided to try OpenShift. I had my app (the same code that wasn't working on Heroku) working perfectly on OpenShift, with websockets and everything, in only 2 hours.

I highly recommend OpenShift to anyone who is looking for free and stable Node.js hosting with WebSockets. Their CLI is just as easy to use as Heroku's, and they give you 3 gears (512MB each) for free!

Here's a couple tips for using Node.js WebSockets on OpenShift:

Use these variables for the server ip and port: var ip = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1"; var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;

But your websocket client should connect to: ws://app-domain.rhcloud.com:8000 or wss://app-domain.rhcloud.com:8443 (for secure https connections)

Source: https://www.openshift.com/blogs/paas-websockets

OTHER TIPS

In my case it was caused by MongoLab being updated and getting out of sync with my version of moongoose. Updating moongoose solved it for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top