5

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?

4
  • Possible duplicate of How to run a simple python script on heroku without flask/django? Commented Sep 24, 2018 at 10:47
  • It's not a possible duplicate of that... First of all, he checked as an answer that he should use Flask, but it's not my case... Commented Sep 24, 2018 at 11:57
  • Hello @SeanYasnogorodski did u manage to put that server to work? Commented Nov 19, 2021 at 0:52
  • @GabrielMarcondes Sorry but no :( Commented Mar 6, 2024 at 14:00

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I am facing a similar issue Can I please get an example code for the same? Thanks!
Hi Can you share your procfile snippet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.