Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

hyper hangs while POSTing to Apple APNS servers #425

Open
@j0nes2k

Description

@j0nes2k

I am using hyper v0.7.0 as a dependency from APNS2 lib (https://github.com/Pr0Ger/PyAPNs2/) for sending out push notifications to iOS devices. We have sporadic but reproducable issues when hyper hangs when POSTing to Apple.

Here is the stack trace when running this in the foreground and aborting finally via Ctrl-C. The call of hyper functions via apns2 happens here: https://github.com/Pr0Ger/PyAPNs2/blob/master/apns2/client.py#L145:

  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/apns2/client.py", line 85, in send_notification
    result = self.get_notification_result(stream_id)
  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/apns2/client.py", line 128, in get_notification_result
    with self._connection.get_response(stream_id) as response:
  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/hyper/http20/connection.py", line 312, in get_response
    return HTTP20Response(stream.getheaders(), stream)
  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/hyper/http20/stream.py", line 230, in getheaders
    self._recv_cb(stream_id=self.stream_id)
  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/hyper/http20/connection.py", line 771, in _recv_cb
    self._single_read()
  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/hyper/http20/connection.py", line 665, in _single_read
    self._sock.fill()
  File "/home/user/.virtualenvs/alertbackend/lib/python3.6/site-packages/hyper/common/bufsocket.py", line 167, in fill
    count = self._sck.recv_into(self._buffer_view[self._buffer_end:])
  File "/usr/lib/python3.6/ssl.py", line 1012, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.6/ssl.py", line 874, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)

Here is the corresponding log output:

[2020-01-13 13:38:47] DEBUG hyper.http20.connection:connect:372 - Selected NPN protocol: h2
[2020-01-13 13:38:47] DEBUG hyper.http20.connection:_recv_cb:759 - recv for stream 0 with set() already present
[2020-01-13 13:38:47] DEBUG hpack.table:maxsize:196 - Resizing header table to 4096 from 4096
[2020-01-13 13:38:47] INFO hyper.http20.connection:_single_read:724 - Received unhandled event <RemoteSettingsChanged changed_settings:{ChangedSetting(setting=SettingCodes.HEADER_TABLE_SIZE, original_value=4096, new_value=4096), ChangedSetting(setting=SettingCodes.MAX_CONCURRENT_STREAMS, original_value=None, new_value=1), ChangedSetting(setting=SettingCodes._max_frame_size, original_value=16384, new_value=16384), ChangedSetting(setting=SettingCodes._max_header_list_size, original_value=None, new_value=8000)}>
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode:233 - HPACK encoding <generator object _check_path_header.<locals>.inner at 0x7fa29a44baf0>
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b':method', b'POST') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 3 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b':scheme', b'https') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 7 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b':authority', b'api.push.apple.com') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 1 with 6 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 13 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b':path', b'/3/device/ios-device-id-here') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 4 with 6 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 53 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b'apns-push-type', b'alert') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 10 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 4 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b'apns-topic', b'app-name-here') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 7 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 21 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b'apns-expiration', b'1578941326') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 11 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 8 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b'authorization', b'bearer auth-bearer-here') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 23 with 4 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 174 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:add:269 - Adding (b'apns-collapse-id', b'14250') to the header table
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 11 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode_integer:62 - Encoding 4 with 7 bits
[2020-01-13 13:38:47] DEBUG hpack.hpack:encode:261 - Encoded header block to b"\x83\x87A\x8d\x1df^\xbbQ:\xe3\xae\xba\n\xb9\x0fOD\xb5a\x96$/s\x10\xac>\xf4\x92\x81\xa0\xc67\x1f\x08\x8a\xfbN\xb6\xdbem\x97\\\x18$rW\xa5|B \n\x12\xb8\xcc\x8c\xca\x17#y\xf7@\xc9\x06\xf9\x00\xd0%\x8d\xb0\x7f@\x8a\x1du!j\xedD\xeb'\xd5e\x84\x1d\x05\xb1?@\x87\x1du!d\x9e\xb3\x13\x95\xa8\xa9_\xc1\xaa\x92SU!l_\xc1\xaa\x92SU!l\x1du\xff@\x8b\x1du!b\xf9\xac\xd6\r&=_\x88\x0bn\xbc\xfbAdN\x7f\x1f\x08\xff/\x8c\xa3\xb0\xb6(_Y@_\xc8M\xa8\xd9sq\x0e\xc3g\xbd\x96x\xf1\x10\xda\x8d\x97\x0f\x0fy\x03\xa4\xd9\x11\x92\x94\xd7\xfb{#\x99:\x9d\xad;\xf8\xf2\xd0\x0f8\xf5_\xd0iv._Yk#:\r\xa8\xd9rr\xdf07\xf4\x9f\x0f\x1d\xf4^\xc8o\x06\x1f, \xc9\xd0\xfet\xef#Z\xb7\xe0oF\xfc\x8c\xe7\xe9\x80\x1a\xaf\xf0\x16\x9f{_]\xbeZ\xeb\x8b\x87\xae;\xb3t?\xb9\xac\xf5\xcf\xf2^r\xd5\xfb\xed\xae\x9a=\x8f\xde\xde\x18/#cZ\xbd\xd7\xfba\xb5x\x87\x8cy.\x9f\x19k\xe7\xa7I\x16\xdd>\x1f>\xe7\xf7\x89\xed\xb1T\x0bf\xf1\xc7\x84C\xeb\x9bI\x9d\xcd\xb3@\x8b\x1du!b\x1e\x8a\x07Z\n\xb1\xa4\x84\x0bBl\x1f"
[2020-01-13 13:38:47] DEBUG hyper.http20.connection:_recv_cb:759 - recv for stream 1 with set() already present

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions