Comments (9)
@bauerj I pressume you are using the pypi version, which is a bit old and will hopefully be updated soon. That version of python-gcm doesn't handle MissingRegistration error received from the GCM server in the raise_error. This problem has been fixed in master branch.
Also in that version there is also a validation made inside the plaintext_request method right at the beginning for the registration_id to be not None, but if your stack trace goes to raise_error it means that the error is coming from the GCM server.
For debugging purposes you can either use a debugger or manually alter the gcm.py
file that you have installed on your machine and inside the make_request
method add two log statements for the following two things and tell use the output:
- Print the request data, add a log statement for the
data
parameter right before therequests.post
call is made to see exactly what the HTTP request data looks like - Print the response data, add a log statement for the
response.content
right after therequests.post
call is made to see exactly what GCM server sends back.
from python-gcm.
Hi,
I already did that: The data variable contains what I posted above and the response only contains Error=MissingRegistration
.
And yes, I'm using the latest version from pypi.
from python-gcm.
OK. So the above data
is what you have right before making the HTTP request.
I'm interested in the exact response from the requests
library not what you get back from python-gcm after processing the response, the response content should have more information.
from python-gcm.
@bauerj I think one more thing is happening. Double URL encoding.
Even though I'm not authorized to send the request I've tried to debug the HTTP request using Wireshark and I see this when using as id fUxwjeZSVR0%3AAPA91bFfRy0DcYw_gxsMd86FEUdwhR6SrvAV46AHhSeWydnYtLMCvza055jXW-e-j-ETDGGCbVaMBN7TdKR8VvdkqLr_pofWkQcsb1o9FE7kqciPvXxYrxYvp98jZttDZSxe3f8dvuM7
POST /gcm/send HTTP/1.1
Host: gcm-http.googleapis.com
Accept: */*
Authorization: key=123api
Content-Length: 244
User-Agent: python-requests/2.8.0
Accept-Encoding: gzip, deflate
Connection: keep-alive
registration_id=fUxwjeZSVR0%253AAPA91bFfRy0DcYw_gxsMd86FEUdwhR6SrvAV46AHhSeWydnYtLMCvza055jXW-e-j-ETDGGCbVaMBN7TdKR8VvdkqLr_pofWkQcsb1o9FE7kqciPvXxYrxYvp98jZttDZSxe3f8dvuM7&data.address=9GWXR4aD6JSb6DMPxAKH9GeGrBDjhRyxuf&data.amount=36.11628274
%3 = :
%3 = %253
=> Double URL/percent encoding is happening
Can you please manually edit the gcm.py file of your installation and delete the following two lines in the make_request method and retry the request:
if not is_json:
data = urlencode_utf8(data)
The requests
HTTP client library already does URL encoding so I think this might be the problem, let me know.
from python-gcm.
@bauerj Any news?
from python-gcm.
Sorry, I was busy earlier today.
Yes, this seems to solve the issue for me.
from python-gcm.
In that case it seems like the plaintext_request was not tested enough before changing to requests library.
This problem is fixed in the master branch.
from python-gcm.
Okay, when will it be fixed on Pypi?
from python-gcm.
@bauerj I will discuss with @geeknam about the next release, we will do it soon.
from python-gcm.
Related Issues (20)
- Help getting started with python-gcm HOT 1
- No support for setting up priority for a given message? HOT 4
- Permission denied error while using send_topic_message() in a GAE environment
- GCM should handle requests exceptions
- if occur retry send request, response info would be wrong (not contain response info of previous request) ?!
- Compatibility with Firebase Cloud Messaging (FCM) ? HOT 4
- Pass GCM (Now FCM) responses to object outputs and not just to the debugger
- request fail HOT 2
- does not handle mixed data & notification messages HOT 1
- Update documentation to include instructions for running unit test cases. HOT 1
- Use nosetest and tox setup to locally run the unit test cases and generate coverage report
- Update to support Notification messages in the FCM payload HOT 2
- Set requests timeout HOT 4
- How to create a vaild GCM API_KEY(sender) and registration token for client(receiver)
- Consider adding deprecation/unmaintained warning to Readme
- DepShield Deprecation Notice
- Sending a message to topic HOT 1
- Not able to access data in service worker HOT 1
- Multiple Resends HOT 7
- python gcm also for IOS HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-gcm.