django-push-notifications icon indicating copy to clipboard operation
django-push-notifications copied to clipboard

hyper.http20.exceptions.StreamResetError: Stream forcefully closed

Open Archideus opened this issue 8 years ago • 10 comments

APNs max_concurrent_streams too high (4294967297), resorting to default maximum (1000) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/site-packages/push_notifications/models.py", line 129, in send_message certfile=certfile, **kwargs File "/usr/local/lib/python3.5/site-packages/push_notifications/apns.py", line 137, in apns_send_bulk_message certfile=certfile, **kwargs File "/usr/local/lib/python3.5/site-packages/push_notifications/apns.py", line 87, in _apns_send **notification_kwargs File "/usr/local/lib/python3.5/site-packages/apns2/client.py", line 122, in send_notification_batch priority, expiration, collapse_id) File "/usr/local/lib/python3.5/site-packages/apns2/client.py", line 78, in send_notification_async stream_id = self._connection.request('POST', url, json_payload, headers) File "/usr/local/lib/python3.5/site-packages/hyper/http20/connection.py", line 281, in request self.endheaders(message_body=body, final=True, stream_id=stream_id) File "/usr/local/lib/python3.5/site-packages/hyper/http20/connection.py", line 546, in endheaders stream = self._get_stream(stream_id) File "/usr/local/lib/python3.5/site-packages/hyper/http20/connection.py", line 289, in _get_stream raise StreamResetError("Stream forcefully closed") hyper.http20.exceptions.StreamResetError: Stream forcefully closed

Archideus avatar Jun 09 '17 14:06 Archideus

+1 The internal implementation for APNS was working as well, but when I've upgraded the package this error raises every time!

Kianoosh76 avatar Aug 23 '17 12:08 Kianoosh76

+1

Using v1.5.0

jksimoniii avatar Oct 02 '17 20:10 jksimoniii

I've opened an issue in the source package page and now the problem is fixed!

Kianoosh76 avatar Oct 08 '17 12:10 Kianoosh76

Facing the same error, what was the solution?

umair151 avatar Dec 09 '17 12:12 umair151

Faced the same error. As @Kianoosh76 reported, it is a problem with use_sandbox. The APNSClient in send_batch_message is not being initialized with the proper arg for use_sandbox.

The solution was to set USE_SANDBOX at every bundle dict in django settings like so. I only needed it in my dev app, so I used a simple check to set it:

for bundle_id in ('com....dev', 'com...dev-alt',
                  'com...staging', 'com...beta'):

    PUSH_NOTIFICATIONS_SETTINGS['APPLICATIONS'][bundle_id] = {                   
        'PLATFORM': 'APNS',
        'CERTIFICATE': get_cert_path(bundle_id),
        'TOPIC': bundle_id,
        'USE_SANDBOX': bundle_id == 'com...dev',
    }

jeffreybrowning avatar Jan 15 '18 19:01 jeffreybrowning

Got the same problem "Stream forcefully closed" here, using production cert and the following settings:

PUSH_NOTIFICATIONS_SETTINGS = { "APNS_TOPIC": Bundle id, "UPDATE_ON_DUPLICATE_REG_ID": True, "APNS_USE_SANDBOX": False }

And I'm passing the production cert file when calling send_message.

martin-xia avatar Jan 15 '18 23:01 martin-xia

Fixed, turns out something is wrong with the generated production cert's subject

martin-xia avatar Jan 16 '18 01:01 martin-xia

I use development cert and my app also in the development. I need to set settings.py DEBUG=True to solve this problem

elcolie avatar Jul 25 '19 16:07 elcolie

Got same issue: cert was generated for sandbox, solution: set APNS_USE_SANDBOX=True, but it may work on opposite way, if you are using production cert with APNS_USE_SANDBOX=True

andrewkoltsov avatar Apr 29 '21 09:04 andrewkoltsov