geeknam / python-gcm

Python client for Google Cloud Messaging for Android (GCM)
MIT License
458 stars 145 forks source link

Receiving a None response #91

Closed nunomarks closed 8 years ago

nunomarks commented 9 years ago

When doing

    reg_id = sample_reg_id
    response = gcm.plaintext_request(registration_id=reg_id, data=data)

The response variable comes as "None". Why so?

nunomarks commented 9 years ago

Found out that it's raising an MissingRegistration error.

alibitek commented 9 years ago

@amportugal Which version of python-gcm are you using? (from where did you install it?)

truyet commented 8 years ago

@mnemonicflow I used version 0.2 and have the same error, after I debug, request is missing header Content-Type: application/x-www-form-urlencoded;charset=UTF-8 ( https://developers.google.com/cloud-messaging/http ) Missing header is reason gcm request sometime success but sometime error. (With request error, I tested by manual request with the same content just add header Content-Type: application/x-www-form-urlencoded;charset=UTF-8)

Thanks.

alibitek commented 8 years ago

@truyet That has been fixed in master branch https://github.com/geeknam/python-gcm/blob/master/gcm/gcm.py#L278 . But this problem might be related #84 which I investigated here: https://github.com/geeknam/python-gcm/issues/84#issuecomment-147240625 and is only reproducible in 0.2 tag We plan to release 0.3 version, in the meantime try the master branch.

truyet commented 8 years ago

@nemonicflow Yes, I used code in master branch and see you fixed it, thank you. But I think you need review retries in gcm request function (plaintext_request, json_request) because it is looped while gcm request is success.

geeknam commented 8 years ago

0.3 is now live: https://pypi.python.org/pypi/python-gcm

alibitek commented 8 years ago

@truyet I will have a look at it. But I haven't found that to be the case. I will try to test your assertion.

alibitek commented 8 years ago

@truyet the problem with the loop inside plaintext_request has been fixed. See #98 and https://github.com/geeknam/python-gcm/commit/6ef1313455f049f318c1381cb5c37238ed24a1aa Getting a None response from plaintext_request when success is a legitimate return value in case where there is no error and the token hasn't changed. (i.e. wasn't replaced by a canonical_id)

We need to provide a way to return the message id when success but still be backwards compatible with old clients that except None as the return value when success.