We're a place where coders share, stay up-to-date and grow their careers.
Hi, I am encountering errrors when creating a websocket connection,
ws = new WebSocket('ws://localhost:8000/') WebSocket {url: "ws://localhost:8000/", readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …} VM50:1 WebSocket connection to 'ws://localhost:8000/' failed: Error during WebSocket handshake: Unexpected response code: 400
And the uvicorn request says: "WARNING: Unsupported upgrade request."
"WARNING: Unsupported upgrade request."
How do I fix this issue?
Thanks.
And also this
ws = new WebSocket('wss://localhost:8000/') WebSocket {url: "wss://localhost:8000/", readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …} ws = new WebSocket('ws://localhost:8000/') WebSocket {url: "ws://localhost:8000/", readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …} ws.onmessage = event => console.log(event.data) event => console.log(event.data) ws.send("ping") VM92:1 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state. at <anonymous>:1:4 (anonymous) @ VM92:1 ws.send("ping") VM97:1 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state. at <anonymous>:1:4 (anonymous) @ VM97:1 VM75:1 WebSocket connection to 'wss://localhost:8000/' failed: WebSocket opening handshake timed out (anonymous) @ VM75:1 VM82:1 WebSocket connection to 'ws://localhost:8000/' failed: Error during WebSocket handshake: Unexpected response code: 400
pip install uvicorn did not deal with WebSocket configuration.
pip install uvicorn
# h11_impl.py L:91 self.ws_protocol_class = config.ws_protocol_class
config.ws_protocol_class is None so in L:264 you will get a warning.
# h11_impl.py L:264 if upgrade_value != b"websocket" or self.ws_protocol_class is None: msg = "Unsupported upgrade request." self.logger.warning(msg)
try: pip install uvicorn[standard] See ref
Hi, I am encountering errrors when creating a websocket connection,
And the uvicorn request says:
"WARNING: Unsupported upgrade request."
How do I fix this issue?
Thanks.
And also this
pip install uvicorn
did not deal with WebSocket configuration.
config.ws_protocol_class is None
so in L:264 you will get a warning.
try: pip install uvicorn[standard]
See ref