jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.28k stars 617 forks source link

URLError at /admin/push_notifications/gcmdevice/ #419

Closed jondanao closed 7 years ago

jondanao commented 7 years ago

Sending push notification to iOS has been successful. But I get this error when sending test message to Android.

The error seems to be happening in gcm.py.

settings.py

PUSH_NOTIFICATIONS_SETTINGS = {
    'FCM_API_KEY': os.environ['FCM_API_KEY'],
    'FCM_POST_URL': os.environ['FCM_POST_URL'],
    'FCM_ERROR_TIMEOUT': 2419200,

    'APNS_CERTIFICATE': os.environ['APNS_CERTIFICATE'],
    'APNS_TOPIC': os.environ['APNS_TOPIC'],
}

Error

<urlopen error [Errno 65] No route to host>

Request Method: POST
Request URL:    http://127.0.0.1:8000/admin/push_notifications/gcmdevice/
Django Version: 1.11.1
Exception Type: URLError
Exception Value:    
<urlopen error [Errno 65] No route to host>
Exception Location: /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in do_open, line 1320
Python Executable:  /Volumes/Workspace/Repositories/MyAPI/venv/bin/python
Python Version: 3.6.1
Python Path:    
['/Volumes/Workspace/Repositories/MyAPI',
 '/Volumes/Workspace/Repositories/MyAPI/venv/lib/python36.zip',
 '/Volumes/Workspace/Repositories/MyAPI/venv/lib/python3.6',
 '/Volumes/Workspace/Repositories/MyAPI/venv/lib/python3.6/lib-dynload',
 '/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
 '/Volumes/Workspace/Repositories/MyAPI/venv/lib/python3.6/site-packages']
Server time:    Fri, 4 Aug 2017 10:44:01 +0800

Did I miss anything in the setup? Thanks!

jamaalscarlett commented 7 years ago

@jondanao What is FCM_POST_URL set to?

jondanao commented 7 years ago

hi @jamaalscarlett https://fcm.googleapis.com/fcm/send

I created a new django project, installed this package and did all the same setup as the project mentioned here. It worked.

So I uninstalled and installed again this package to the existing project. But error still persists. I'm lost. I can't pinpoint if it clashes with other installed packages. Here's my requirements.txt:

apns2==0.3.0
appdirs==1.4.3
asn1crypto==0.22.0
boto==2.48.0
cffi==1.10.0
cookies==2.2.1
coverage==4.4.1
cryptography==2.0.2
Django==1.11.1
django-bootstrap-form==3.2.1
django-debug-toolbar==1.8
django-push-notifications==1.5.0
django-storages==1.6.3
djangorestframework==3.6.3
drf-tracking==1.2.0
Faker==0.7.18
h2==2.6.2
hpack==3.0.0
hyper==0.7.0
hyperframe==3.2.0
idna==2.5
olefile==0.44
packaging==16.8
phonenumbers==8.6.0
Pillow==4.1.1
psycopg2==2.7.1
py==1.4.33
pycparser==2.18
Pygments==2.2.0
PyJWT==1.5.2
pyparsing==2.2.0
pytest==3.1.0
pytest-cov==2.5.1
pytest-django==3.1.2
pytest-mock==1.6.2
pytest-sugar==0.8.0
python-dateutil==2.6.1
pytz==2017.2
requests==2.14.2
responses==0.5.1
six==1.10.0
sqlparse==0.2.3
termcolor==1.1.0
jamaalscarlett commented 7 years ago

"No route to host" That sounds like a networking issue. Can you ping the fcm endpoint from the server? Does a curl command from the server work?

jondanao commented 7 years ago

@jamaalscarlett : sure is a networking issue. On my local machine, I get this error, but when I execute this on AWS, it does work just fine. Can't really figure out what's causing the error.

This error has nothing to do with this library.