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

大兔子大兔子 提交于 2020-03-20 11:58:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/52477103/how-to-host-websocket-app-python-server-on-heroku-without-flask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!