Sean Yasnogorodski
Sean Yasnogorodski

Reputation: 128

How to host websocket app python server on Heroku without Flask?

So I'm making a school project and I have to make a python server and android client. So I've already created a server using websockets with python 3 (I'm not using Flask or socket.io and etc, just regular websockets) and a client in android studio. I ran everything locally and it works great!

So now I want to go up in a level a little bit, I want to host my server on Heroku. I tried but I have some problems with that... As I mentioned, I'm using only websockets and not Flask and that means that I need to specify a host ip/url and a port. But when I host the server on Heroku it says that "address already in use".

Does anyone know how solve it?

Upvotes: 5

Views: 2030

Answers (1)

Bikalpa Dulal
Bikalpa Dulal

Reputation: 66

You can host in heroku by using the ip "0.0.0.0", and get the port from the env variable called "PORT". On the client you can connect to the websocket server using "wss://yourherokuapp.herokuapp.com/0.0.0.0". Make sure on your Procfile your script is running as a web process type.

Upvotes: 5

Related Questions