h11._util.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
See original GitHub issueI intermittently got this error when load testing uvicorn endpoint.
This error comes from a proxy endpoint where I am also using encode/http3
to perform HTTP client calls.
File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 365, in post
timeout=timeout,
File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 497, in request
timeout=timeout,
File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 112, in send
allow_redirects=allow_redirects,
File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 145, in send_handling_redirects
request, verify=verify, cert=cert, timeout=timeout
File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 121, in send
raise exc
File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 116, in send
request, verify=verify, cert=cert, timeout=timeout
File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection.py", line 59, in send
response = await self.h11_connection.send(request, timeout=timeout)
File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 65, in send
event = await self._receive_event(timeout)
File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 109, in _receive_event
event = self.h11_state.next_event()
File "/project/venv/lib/python3.7/site-packages/h11/_connection.py", line 439, in next_event
exc._reraise_as_remote_protocol_error()
File "/project/venv/lib/python3.7/site-packages/h11/_util.py", line 72, in _reraise_as_remote_protocol_error
raise self
File "/project/venv/lib/python3.7/site-packages/h11/_connection.py", line 422, in next_event
self._process_event(self.their_role, event)
File "/project/venv/lib/python3.7/site-packages/h11/_connection.py", line 238, in _process_event
self._cstate.process_event(role, type(event), server_switch_event)
File "/project/venv/lib/python3.7/site-packages/h11/_state.py", line 238, in process_event
self._fire_event_triggered_transitions(role, event_type)
File "/project/venv/lib/python3.7/site-packages/h11/_state.py", line 253, in _fire_event_triggered_transitions
.format(event_type.__name__, role, self.states[role]))
h11._util.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
Issue Analytics
- State:
- Created 4 years ago
- Comments:108 (51 by maintainers)
Top Results From Across the Web
can't handle event type Response when role=SERVER and ...
Every 10-12h I have the following error: LocalProtocolError( h11._util.LocalProtocolError: can't handle event type Response when role=SERVER ...
Read more >API documentation — h11 0.14.0+dev documentation
A marker that indicates whether this data object is from the start of a chunked transfer encoding chunk. This field is ignored when...
Read more >A brand new website interface for an even better experience!
h11._util.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are two web servers.
testapp.py
testapp1.py
The reproduce steps:
http://127.0.0.1:8000/
in browserThis happens, not every time. The logs again:
Sorry for my poor English.
I don’t think there are any actual behavioral bugs being discussed in this thread. It’s just about how to give a better error message. So I think either there’s something wrong with your server setup that’s causing it to close connections abruptly without sending responses, or else you’ve found a different bug in httpx and should probably open a new issue so your problem doesn’t get lost in the noise.