Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionTerminated error_code:ErrorCodes.NO_ERROR #45

Closed
victoraugustolls opened this issue Mar 11, 2020 · 12 comments
Closed

ConnectionTerminated error_code:ErrorCodes.NO_ERROR #45

victoraugustolls opened this issue Mar 11, 2020 · 12 comments
Labels

Comments

@victoraugustolls
Copy link
Contributor

With httpx using httpcore interface, started receiving the following error:

<ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:1999, additional_data:None>

Don't know h2 specifics to say, but could NO_ERROR be used for some indication like graceful connection closing rather than raising an error?

@tomchristie
Copy link
Member

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.)

@victoraugustolls
Copy link
Contributor Author

I had in the past, will try to get a new one.

@tomchristie
Copy link
Member

Looks like we deal with this correctly now, so I'm going to close it off, pending re-occurrence.

@victoraugustolls
Copy link
Contributor Author

victoraugustolls commented Jul 16, 2020

Hi @tomchristie , so... it happened again (tagging @yeraydiazdiaz and @florimondmanca also)!

Here is the traceback:

2020-07-16T15:28:11.813909653Z     response = await self.send(
2020-07-16T15:28:11.813913353Z   File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1168, in send
2020-07-16T15:28:11.813917153Z     response = await self.send_handling_redirects(
2020-07-16T15:28:11.813920953Z   File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1195, in send_handling_redirects
2020-07-16T15:28:11.813924853Z     response = await self.send_handling_auth(
2020-07-16T15:28:11.813929653Z   File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1232, in send_handling_auth
2020-07-16T15:28:11.813933653Z     response = await self.send_single_request(request, timeout)
2020-07-16T15:28:11.813937453Z   File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1264, in send_single_request
2020-07-16T15:28:11.813941353Z     ) = await transport.request(
2020-07-16T15:28:11.813944953Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 152, in request
2020-07-16T15:28:11.813948953Z     response = await connection.request(
2020-07-16T15:28:11.813952653Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 78, in request
2020-07-16T15:28:11.813956554Z     return await self.connection.request(method, url, headers, stream, timeout)
2020-07-16T15:28:11.813960654Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http2.py", line 118, in request
2020-07-16T15:28:11.813964554Z     return await h2_stream.request(method, url, headers, stream, timeout)
2020-07-16T15:28:11.813970554Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http2.py", line 292, in request
2020-07-16T15:28:11.813974454Z     status_code, headers = await self.receive_response(timeout)
2020-07-16T15:28:11.813978154Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http2.py", line 344, in receive_response
2020-07-16T15:28:11.813982154Z     event = await self.connection.wait_for_event(self.stream_id, timeout)
2020-07-16T15:28:11.813986054Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http2.py", line 197, in wait_for_event
2020-07-16T15:28:11.813989954Z     await self.receive_events(timeout)
2020-07-16T15:28:11.813993654Z   File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http2.py", line 211, in receive_events
2020-07-16T15:28:11.813997454Z     raise ProtocolError(event)
2020-07-16T15:28:11.814001354Z httpcore._exceptions.ProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:1999, additional_data:None>```

@nathalie21005
Copy link

Hi @victoraugustolls,

How did you solve this issue, I am facing the same problem.
Thank you

@victoraugustolls
Copy link
Contributor Author

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
Copy link

hey @victoraugustolls , thank you for replying. Can I know which version are you using for httpcore? thanks

@victoraugustolls
Copy link
Contributor Author

I'm using it through httpx version v0.21.3

@twisteroidambassador
Copy link

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:

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>

@tyteen4a03
Copy link

Hi, also running into this issue.

@twisteroidambassador
Copy link

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.

sanderegg added a commit to sanderegg/osparc-simcore that referenced this issue Oct 25, 2022
sanderegg added a commit to sanderegg/osparc-simcore that referenced this issue Oct 25, 2022
sanderegg added a commit to sanderegg/osparc-simcore that referenced this issue Oct 26, 2022
@theChampionOne
Copy link

same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants