首页 > 解决方案 > django推送通知抛出gcm错误

问题描述

我正在使用 django 推送通知,但有时会收到以下错误

raised unexpected: GCMError({'multicast_id': 1826728239203974173, 'success': 4, 'failure': 1, 'canonical_ids': 0, 'results': [{'message_id': '0:1605278994023650%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994028849%2fd9afcdf9fd7ecd'}, {'error': 'InternalServerError'}, {'message_id': '0:1605278994038573%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994030881%cc9b4facf9fd7ecd'}]},)
Traceback (most recent call last):
  File "/home/project/server-side/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/project/server-side/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 629, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/project/server-side/app/tasks.py", line 299, in alarm_users
    is_business_app=True,
  File "/home/project/server-side/tools/utils.py", line 246, in send_push
    web_devices.send_message(None, extra=kwargs, use_fcm_notifications=True)
  File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/models.py", line 73, in send_message
    r = gcm_send_message(reg_ids, data, cloud_type, application_id=app_id, **kwargs)
  File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/gcm.py", line 209, in send_message
    chunk, data, cloud_type=cloud_type, application_id=application_id, **kwargs
  File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/gcm.py", line 166, in _cm_send_request
    return _cm_handle_response(registration_ids, response, cloud_type, application_id)
  File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/gcm.py", line 111, in _cm_handle_response
    raise GCMError(response)
push_notifications.gcm.GCMError: {'multicast_id': 1826728239203974173, 'success': 4, 'failure': 1, 'canonical_ids': 0, 'results': [{'message_id': '0:1605278994023650%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994028849%2fd9afcdf9fd7ecd'}, {'error': 'InternalServerError'}, {'message_id': '0:1605278994038573%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994030881%cc9b4facf9fd7ecd'}]}

最有趣的是它有时可以工作,但有时我还没有找到错误。如果有人以前遇到过这个问题或者有人知道如何解决这个问题。请问你能帮忙吗?提前致谢!

标签: pythondjangodjango-rest-frameworkdjango-push-notifications

解决方案


推荐阅读