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
Do you know what the traceback is on this? Really we need to be catching that case in the HTTP/2 connection class and mapping it to a NewConnectionRequired exception. (The server is indicating that it has served the maximum number of streams that it'll allow on a connection, and that the client should reopen a new connection.)
I think I have run into the same issue. After issuing many requests on an http2 connection using httpx, all subsequent requests fail immediately with httpx.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:19999, additional_data:None>.
Traceback (most recent call last):
File "~\venv\lib\site-packages\h2\connection.py", line 224, in process_input
func, target_state = self._transitions[(self.state, input_)]
KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.SEND_HEADERS: 0>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "~\venv\lib\site-packages\httpcore\_async\http2.py", line 105, in handle_async_request
await self._send_request_headers(request=request, stream_id=stream_id)
File "~\venv\lib\site-packages\httpcore\_async\http2.py", line 202, in _send_request_headers
self._h2_state.send_headers(stream_id, headers, end_stream=end_stream)
File "~\venv\lib\site-packages\h2\connection.py", line 766, in send_headers
self.state_machine.process_input(ConnectionInputs.SEND_HEADERS)
File "~\venv\lib\site-packages\h2\connection.py", line 228, in process_input
raise ProtocolError(
h2.exceptions.ProtocolError: Invalid input ConnectionInputs.SEND_HEADERS in state ConnectionState.CLOSED
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "~\venv\lib\site-packages\httpx\_transports\default.py", line 60, in map_httpcore_exceptions
yield
File "~\venv\lib\site-packages\httpx\_transports\default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "~\venv\lib\site-packages\httpcore\_async\connection_pool.py", line 253, in handle_async_request
raise exc
File "~\venv\lib\site-packages\httpcore\_async\connection_pool.py", line 237, in handle_async_request
response = await connection.handle_async_request(request)
File "~\venv\lib\site-packages\httpcore\_async\connection.py", line 90, in handle_async_request
return await self._connection.handle_async_request(request)
File "~\venv\lib\site-packages\httpcore\_async\http2.py", line 138, in handle_async_request
raise RemoteProtocolError(self._connection_error_event)
httpcore.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:19999, additional_data:None>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "~\decryptor.py", line 138, in do_decrypt_work
resp = await client.get(test_v3_url)
File "~\venv\lib\site-packages\httpx\_client.py", line 1729, in get
return await self.request(
File "~\venv\lib\site-packages\httpx\_client.py", line 1506, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "~\venv\lib\site-packages\httpx\_client.py", line 1593, in send
response = await self._send_handling_auth(
File "~\venv\lib\site-packages\httpx\_client.py", line 1621, in _send_handling_auth
response = await self._send_handling_redirects(
File "~\venv\lib\site-packages\httpx\_client.py", line 1658, in _send_handling_redirects
response = await self._send_single_request(request)
File "~\venv\lib\site-packages\httpx\_client.py", line 1695, in _send_single_request
response = await transport.handle_async_request(request)
File "~\venv\lib\site-packages\httpx\_transports\default.py", line 352, in handle_async_request
with map_httpcore_exceptions():
File "AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "~\venv\lib\site-packages\httpx\_transports\default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:19999, additional_data:None>
Reacted by Timothy Choi, saschnet, Dmitry Agafonov, Eric Guan and 双草酸酯
the "user"-side solution is to wait with the requests until the connection is reestablished. that takes some user-side logic. I wish the library did that on its own in some way.
Activity
lovelydinosaur commentedon May 13, 2020
Do you know what the traceback is on this? Really we need to be catching that case in the HTTP/2 connection class and mapping it to a
NewConnectionRequiredexception. (The server is indicating that it has served the maximum number of streams that it'll allow on a connection, and that the client should reopen a new connection.)victoraugustolls commentedon May 13, 2020
I had in the past, will try to get a new one.
lovelydinosaur commentedon May 14, 2020
Looks like we deal with this correctly now, so I'm going to close it off, pending re-occurrence.
victoraugustolls commentedon Jul 16, 2020
Hi @tomchristie , so... it happened again (tagging @yeraydiazdiaz and @florimondmanca also)!
Here is the traceback:
nathalie21005 commentedon Jan 19, 2022
Hi @victoraugustolls,
How did you solve this issue, I am facing the same problem.
Thank you
victoraugustolls commentedon Jan 19, 2022
Hey @nathalie21005 ! I don't have this issue on recent httpcore versions! Also, my assumption is that it was a host problem, not a client one!
nathalie21005 commentedon Jan 19, 2022
hey @victoraugustolls , thank you for replying. Can I know which version are you using for httpcore? thanks
victoraugustolls commentedon Jan 19, 2022
I'm using it through
httpxversion v0.21.3twisteroidambassador commentedon Mar 7, 2022
I think I have run into the same issue. After issuing many requests on an http2 connection using httpx, all subsequent requests fail immediately with
httpx.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:19999, additional_data:None>.Package versions:
h2-4.1.0
httpcore-0.14.7
httpx-0.22.0
Full traceback:
tyteen4a03 commentedon Mar 13, 2022
Hi, also running into this issue.
twisteroidambassador commentedon Mar 15, 2022
I have created a discussion topic for this problem over at httpx's repository: encode/httpx#2112
Perhaps we can get more attention over there.
fix issue: encode/httpcore#45
fix issue: encode/httpcore#45
fix issue: encode/httpcore#45
theChampionOne commentedon Oct 7, 2024
same problem
crackwitz commentedon Sep 29, 2025
the "user"-side solution is to wait with the requests until the connection is reestablished. that takes some user-side logic. I wish the library did that on its own in some way.