Heroku, flask, and python sockets? Heroku, flask, and python sockets? flask flask

Heroku, flask, and python sockets?


When running on Heroku, your server should bind to port specified in the environment variable PORT (say 7880, just for the sake of this discussion). It is not guaranteed to be 80, 5000, 8000, 8080, or anything else.

To the outside world, however, this will appear as port 80 or port 443. That is, if connecting from outside of Heroku, your client will be connecting to port 80.

One final caveat: when connecting from outside Heroku, your client will go thru the "Heroku Routing Mesh", which among other things does the 80-->something port "translation". The thing is, the routing mesh is an HTTP routing mesh: it will only accept incoming HTTP requests, and will route them (after sometimes altering them, like adding headers etc.) to your dyno.

So you can't just write a plain-sockets app on the Heroku and connect to it directly, you'll have to use HTTP as your transport.