Heroku error 503, webSockets on multiple domains

2019-07-21 21:18发布

问题:

I'm experiencing a 503 error with heroku on my project using WebSockets and a custom domain.

  • Connecting on http://www.mydomain.com (That point with CNAME on my heroku app)

WebSocket connection to 'ws://www.mydomain.com/shoutbox' failed: Error during WebSocket handshake: Unexpected response code: 503

  • Connecting on http://myapp.herokuapp.com

Everything goes allright with adress ws://myapp.herokuapp.com/shoutbox. Everything is also good in my local setup.

Is there any cross-domain issue I'm not aware off ? I'm using play!2 as server side fwk, but I don't think there is any relation to this problem.

[EDIT] If I can only connect within my own domain then it would be fine. Cause this would be the address I'd like people to use.

回答1:

I'm assuming you already enabled heroku labs:enable websockets since your herokuapp domain is working properly.

I have a hunch your DNS query is hitting a Heroku endpoint that doesn't support websockets, i.e. it's cached from before you enabled the websockets functionality.

If this behavior only happens on a single client, try flushing your DNS cache and trying again. Alternatively, make sure the DNS records for both of your domains are resolving to the same IP.