Skip to content

Connection aborted.', RemoteDisconnected('Remote end closed connection without response') #39

@SaadEddineSaad97

Description

@SaadEddineSaad97

How can we help?

Hello All,
using the python onesignal SDK , and while sending push notifications to our application users, sometimes we receive Connection aborted.', RemoteDisconnected('Remote end closed connection without response') .

api_response = OneSignalClient._api_instance.create_notification(notification)

when checked the documentation i found that when calling create notification we may face 429 too many requests ( it may be the reason) .

I tried to reproduce it but i didnt arrived to do .

Any idea ?

We are using onesignal-python-api==2.0.2

Exception trace :

File "/usr/local/lib/python3.11/contextlib.py", line 81, in inner
            ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
    response.begin()
    response = self.handle_exception(exc)
  File "/opt/venv/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
http.client.RemoteDisconnected: Remote end closed connection without response
  File "/opt/venv/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
Traceback (most recent call last):
    return self.create(request, *args, **kwargs)
  File "/opt/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
  File "/opt/venv/lib/python3.11/site-packages/rest_framework/mixins.py", line 24, in perform_create
    return func(*args, **kwds)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    self.send_notification(owner, validated_data["notification_type"], **validated_data["notification_payload"])
    return self.dispatch(request, *args, **kwargs)
    Notification.objects.push(notification_keys, title, body)
    return OneSignalClient.push_notification_to_onesignal(notification_keys, title, body)
    raise exc
    response = handler(request, *args, **kwargs)
  File "/opt/venv/lib/python3.11/site-packages/rest_framework/generics.py", line 190, in post
  File "/opt/venv/lib/python3.11/site-packages/onesignal/api_client.py", line 881, in call_with_http_info
            ^^^^^^^^^^^^^^^^^^^^^^^^^
    serializer.save()
  File "/opt/venv/lib/python3.11/site-packages/onesignal/api_client.py", line 200, in __call_api
  File "/app/api/serializers.py", line 176, in create
    return self.rest_client.POST(url,
  File "/app/api/models.py", line 74, in push_notification
  File "/app/api/models.py", line 137, in push
    r = self.pool_manager.request(
  File "/opt/venv/lib/python3.11/site-packages/urllib3/_request_methods.py", line 143, in request
  File "/opt/venv/lib/python3.11/site-packages/onesignal/api/default_api.py", line 2662, in create_notification
    return self.urlopen(method, url, **extra_kw)
    return self.api_client.call_api(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/elasticapm/instrumentation/packages/urllib3.py", line 132, in call
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/onesignal/api_client.py", line 469, in request
  File "/opt/venv/lib/python3.11/site-packages/urllib3/util/retry.py", line 474, in increment
    return self.request("POST", url,
    raise value.with_traceback(tb)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    return self.request_encode_body(
               ^^^^^^^^^^^^^^^^^^
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.11/http/client.py", line 1395, in getresponse
                               ^^^^^^^^^^^^^^^^^^^
    raise RemoteDisconnected("Remote end closed connection without"
Traceback (most recent call last):
    response = self._make_request(
  File "/opt/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 534, in _make_request
               ^^^^^^^^^^^^^^^^^^
    httplib_response = super().getresponse()
  File "/usr/local/lib/python3.11/http/client.py", line 1395, in getresponse
  File "/usr/local/lib/python3.11/http/client.py", line 325, in begin
                               ^^^^^^^^^^^^^^^^^^^
    raise RemoteDisconnected("Remote end closed connection without"
During handling of the above exception, another exception occurred:
  File "/opt/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
               ^^^^^^^^^^^^^^^^^^^^^
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
               ^^^^^^^^^^^^^^^^^^^
    return view_func(*args, **kwargs)
    response = conn.getresponse()
  File "/opt/venv/lib/python3.11/site-packages/urllib3/connection.py", line 516, in getresponse
                        ^^^^^^^^^^^^^^^^^^^^^
    response.begin()
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.11/http/client.py", line 294, in _read_status
  File "/opt/venv/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions