ERR_CONNECTION_REFUSED with WebSocket
laundrevity opened this issue · comments
I am unable to use web sockets inside of the docker container. My JavaScript:
var ws = new WebSocket("ws://localhost:80/ws");
and my Python route:
@app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): await websocket.accept() while True: data = await websocket.receive_text() await websocket.send_text(f"Message text was: {data}")
This is using tiangolo/uvicorn-gunicorn:python3.6-alpine3.8.
Thanks!
I needed to add the URL of the remote host, not localhost...
Thanks for reporting back and closing the issue @laundrevity 👍