You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When establishing a WebSocket connection over SSL, if the server process is abruptly terminated via kill -9, the reverse proxy cannot gracefully handle the exception.
To Reproduce
Run the server:
# ws-server.pyimportasynciofromfastapiimportFastAPI, WebSocketapp=FastAPI()
@app.websocket("/ws")asyncdefwebsocket_endpoint(websocket: WebSocket):
awaitwebsocket.accept()
print("Client connected")
response=awaitwebsocket.receive()
print(f"Received: {response}")
awaitasyncio.sleep(100)
awaitwebsocket.send_text("Success: The request completed after 100 seconds.")
print("Response sent to client")
if__name__=="__main__":
importuvicornuvicorn.run(
app, host="0.0.0.0", port=8766, ssl_certfile="cert.pem", ssl_keyfile="key.pem"
)
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=localhost"
$ python ./ws-server.py
INFO: Started server process [32042]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on https://0.0.0.0:8766 (Press CTRL+C to quit)
$ python ./ws-rs.py
INFO: Started server process [31689]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8765 (Press CTRL+C to quit)
Thanks! Thank you for your report and the PR you linked.
I haven't looked into this issue in detail; since the PR you linked has already been merged, do we just need to upgrade HTTPX to the latest version? (if i am wrong, please correct me)
I haven't looked into this issue in detail; since the PR you linked has already been merged, do we just need to upgrade HTTPX to the latest version? (if i am wrong, please correct me)
Thank you for the prompt response! To clarify, the test suite is already using the latest HTTPX and HTTPX-WS release.
Describe the Bug
When establishing a WebSocket connection over SSL, if the server process is abruptly terminated via
kill -9
, the reverse proxy cannot gracefully handle the exception.To Reproduce
$ python ./ws-rs.py INFO: Started server process [31689] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8765 (Press CTRL+C to quit)
$ python ./ws-client.py Connected to WebSocket server Sent: Hello, WebSocket Server!
Expected Behavior
Exceptions should be gracefully handled, not thrown out (or exposed).
Configuration
The text was updated successfully, but these errors were encountered: