Skip to content

[Bug]: TimeoutError: The read operation timed out #23

Open
@ahmedesmail07

Description

@ahmedesmail07

What happened?

Description

When using the OneSignal SDK, I encountered a TimeoutError with the message "The read operation timed out." While sending some notifications, some of them were sent and other are not. This issue is causing unexpected behavior in my application.
the problem was occurred at response = client.send_notification(notification)


@shared_task(bind=True)
def notify_user(self, id):
    if settings.TEST:
        logger.info("push notification on CircleCi")
        return
    try:
        instance = NotificationModel.objects.get(pk=id)
    except NotificationModel.DoesNotExist:
        logger.info('Notification is not found')
        return
    notification = dict()
    if settings.ONESIGNAL_SANDBOX:
        to = [settings.ONESIGNAL_TEST_PLAYER_ID]
    elif not instance.user.devices.exists():
        logger.info('User {} has not devices attached'.format(instance.user.email))
        return
    else:
        to = list(map(lambda d: d.player_id, instance.user.devices.filter(player_id__isnull=False)))
        if len(to) == 0:
            return
    notification['include_player_ids'] = to
    notification['contents'] = {
        'en': instance.content
    }
    notification['headings'] = {
        'en': instance.title,
    }
    notification['ios_badgeType'] = 'Increase'
    notification['ios_badgeCount'] = 1
    try:
        response = client.send_notification(notification)
    except Exception as e:
        logger.info(f"Error is {e}")
        raise self.retry(max_retries=5, countdown=(30), exc=e)
    return response.body

Steps to reproduce?

1- Trying to push notification to the user. Some notification were sent successfully other not.

What did you expect to happen?

The notification should be sent successfully.

Relevant log output

ReadTimeout
The read operation timed out

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions