Intermittent exceptions when using NAV API
The script nettinst2room
intermittently throws Excpetions like:
can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/httpx/_exceptions.py", line 326, in map_exceptions
yield
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 866, in _send_single_request
ext={"timeout": timeout.as_dict()},
File "/usr/local/lib/python3.7/dist-packages/httpcore/_sync/connection_pool.py", line 219, in request
method, url, headers=headers, stream=stream, ext=ext
File "/usr/local/lib/python3.7/dist-packages/httpcore/_sync/connection.py", line 106, in request
return self.connection.request(method, url, headers, stream, ext)
File "/usr/local/lib/python3.7/dist-packages/httpcore/_sync/http11.py", line 72, in request
) = self._receive_response(timeout)
File "/usr/local/lib/python3.7/dist-packages/httpcore/_sync/http11.py", line 133, in _receive_response
event = self._receive_event(timeout)
File "/usr/local/lib/python3.7/dist-packages/httpcore/_sync/http11.py", line 169, in _receive_event
event = self.h11_state.next_event()
File "/usr/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.7/dist-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc) from None
httpcore.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/simple_rest_client/decorators.py", line 29, in wrapper
response = f(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/simple_rest_client/request.py", line 25, in make_request
client_response = client_method(request.url, **client_options)
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 915, in get
timeout=timeout,
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 734, in request
request, auth=auth, allow_redirects=allow_redirects, timeout=timeout
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 772, in send
history=[],
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 809, in _send_handling_auth
history=history,
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 837, in _send_handling_redirects
response = self._send_single_request(request, timeout)
File "/usr/local/lib/python3.7/dist-packages/httpx/_client.py", line 866, in _send_single_request
ext={"timeout": timeout.as_dict()},
File "/usr/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.7/dist-packages/httpx/_exceptions.py", line 343, in map_exceptions
raise mapped_exc(message, **kwargs) from exc # type: ignore
httpx.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
Error in fetching room for un-p000003:
Error: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
The failed API requests do not seem to appear at all in the logs on the server! (/var/log/apache2/nav-secure_access_ssl.log /var/log/uwsgi/app/nav.log /var/log/uwsgi/nav/nav.log)
Is this some kind of throttling on the server side?
Related to this? https://github.com/encode/httpx/issues/1478