HENNGE / aapns

Asynchronous Apple Push Notifications

Home Page:https://aapns.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid input ConnectionInputs.RECV_HEADERS in state ConnectionState.CLOSED

dimaqq opened this issue · comments

Got this error and traceback in production:

ProtocolError
Invalid input ConnectionInputs.RECV_HEADERS in state ConnectionState.CLOSED

h2/connection.py in process_input at line 228

h2/connection.py in _receive_headers_frame at line 1554

h2/connection.py in _receive_frame at line 1486

h2/connection.py in receive_data at line 1463

aapns/connection.py in background_read at line 300

Current code in question is:

while not self.closed:
data = await self.read_stream.read(2 ** 16)
if not data:
raise ConnectionError("Server closed the connection")
for event in self.protocol.receive_data(data):
logger.debug("APN: %s", event)
stream_id = getattr(event, "stream_id", 0)
error = getattr(event, "error_code", None)
channel = self.channels.get(stream_id)

Also, looks like that prod was not running the newest aapns 🤔

In short, h2 knows that the connection is closed, but aapns background read coro does not?

I can think of two possibilities:

  • connection got closed during reveive_data (as that can receive many packets at once), or
  • background coro read/write/aclose machinery lost the memo