new GCM version

1,359 views
Skip to first unread message

francesco nerieri

unread,
Aug 2, 2012, 1:00:14 AM8/2/12
to andro...@googlegroups.com
Hi there,

we rolled out a few more features this week:
1- the format of the values in the data section of your JSON request
must be a string
2- 'from' has historically been a reserved keyword in C2DM/GCM, we
added a check that if you use the "from" key in your data section we
will return an error. From now on all reserved keys will have the
format: google.key
3- we added a 'dry run' feature for you to test your request without
actually sending a message; in the payload simply add the parameter:
"dry_run = true". GCM will validate your messages without actually
sending it

Cheers,
f

---
https://plus.google.com/u/0/104524825852741167674

Luca Morettoni

unread,
Aug 14, 2012, 8:35:19 AM8/14/12
to andro...@googlegroups.com
On Thu, Aug 2, 2012 at 7:00 AM, francesco nerieri
<francesc...@gmail.com> wrote:
> 3- we added a 'dry run' feature for you to test your request without
> actually sending a message; in the payload simply add the parameter:
> "dry_run = true". GCM will validate your messages without actually
> sending it

francesco, this is a great feature of GCM, but I don't see it in the
documentation/examples...

--
Luca Morettoni <luca(AT)morettoni.net> | http://www.morettoni.net
gtalk/msn: luca(AT)morettoni.net | http://twitter.com/morettoni
Google+ profile: http://bit.ly/morettoni_plus
Member of Python User Group Perugia: http://www.pypg.org/

Luca Morettoni

unread,
Aug 14, 2012, 8:37:52 AM8/14/12
to andro...@googlegroups.com
On Tue, Aug 14, 2012 at 2:35 PM, Luca Morettoni <lu...@morettoni.net> wrote:
> francesco, this is a great feature of GCM, but I don't see it in the
> documentation/examples...

sorry, found here:
http://developer.android.com/guide/google/gcm/gcm.html

:)

flyingbag

unread,
Sep 8, 2012, 2:57:20 PM9/8/12
to andro...@googlegroups.com
Hello Francesco,
I saw your entire presentation here. It was very helpful! 

In this group there are several discussions around delays in GCM deliver. I studied those and tried to device a solution where these can be minimized. The most reliable way seems to be set TTL to 0 so that GCM doesnt need to store or que these messages...

I have some questions around GCM message delivery behavious that i observed:
- If one sets the TTL as 0 and delay_while_idle=false, i believe that message is not stored on GCM and sent to device immediately. However - i have done extensive testing on my side and the observation is that GCM is unable to deliver ALL these messages to the target device. 
What i think happens (in theory)
- Throttling should not be happening in this case - since the TTL is 0 and delay_while_idle is false - which means - GCM receives msg from app server and immediately shoots it off to the device
What i observe real time:
- If the device is active (lets say i have a phone call on going, or browsing the internet) - the message is received immediately almost every time. However  - when the device is not active - the GCM delivery is inconsitent - sometime you get the message - sometimes you dont... I have made sure to keep Phone Wake Lock on receiving the intent - so that problem is ruled out. The device is connected to the WIFI all the time since i am testing with a ping to my app server every minute! 
- I even tested sending 50 msgs in rapid succession once the device is active - and all of them were received successfully

So - in this case - do you think there is some throttling that is done by GCM? Or something else going on here?
Appreciate your response and of course - a BIG THANK you to you guys for this fantastic service. Hope it keeps improving and many more features get added as it matures !

Cheers
flyingbag

Justin W. Russell

unread,
Sep 17, 2012, 6:02:52 PM9/17/12
to andro...@googlegroups.com
Hello,

Has the dry_run feature been tested with json as the content type?  I am able to get it to work using plain text as the content type, but not with json.  If it does work, can you post a dump of what the message body looks like with it working?

Thanks,
Justin

Martin Revert

unread,
Sep 19, 2012, 12:19:02 AM9/19/12
to andro...@googlegroups.com
Hi Justin, "dry_run" is not working for me neither using JSON.
I've tried to bring this to Francesco's attention on G+, but with no success.

Pablo Dal Lago

unread,
Sep 19, 2012, 1:55:32 PM9/19/12
to andro...@googlegroups.com
Check that you're passing dry_run as an HTTP parameter, not as a field inside the JSON object.

The docs say: "If you want to test your request (either JSON or plain text) without delivering the message to the devices, you can set an optional HTTP parameter (emphasis mine) called dry_run with the value true."

--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-gcm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/android-gcm/-/RNS10n8awm0J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Justin W. Russell

unread,
Sep 19, 2012, 2:43:41 PM9/19/12
to andro...@googlegroups.com
Can you explain what you mean by HTTP Parameter?  Do you mean as part of the url?  e.g.:

https://android.googleapis.com/gcm/send?dry_run=true

Because that doesn't work.  Like I said previously, the only way I've successfully performed a dry run is if I use plain text as the content type (i.e., Content-Type:application/x-www-form-urlencoded;charset=UTF-8) and then set dry_run=true is part of the content itself.  If anyone has successfully done this when using JSON, can you post the details on how you accomplished this?

Thanks,
Justin

Pablo Dal Lago

unread,
Sep 19, 2012, 3:16:30 PM9/19/12
to andro...@googlegroups.com
On Wed, Sep 19, 2012 at 11:43 AM, Justin W. Russell <jus...@rowshambow.com> wrote:
Can you explain what you mean by HTTP Parameter?  Do you mean as part of the url?  e.g.:

https://android.googleapis.com/gcm/send?dry_run=true

Yes. Because the content type for JSON requests is "application/json", additional HTTP parameters can't be in the request body and must be encoded in the URL.
 
Because that doesn't work.

It should work. Can you post a dump of the request you're sending and the response you get? How do you know it's not working? i.e. What would you expect to see and what do you see instead.

Justin W. Russell

unread,
Sep 20, 2012, 2:32:11 PM9/20/12
to andro...@googlegroups.com
Ok, I'm not sure why or what changed, but it appears to now be working for me.  For reference, for those using php/curl, here is the output of curl_getinfo() with dry_run working:

        (
            [url] => https://android.googleapis.com/gcm/send?dry_run=true
            [content_type] => application/json; charset=UTF-8
            [http_code] => 200
            [header_size] => 314
            [request_size] => 450
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 0.585318
            [namelookup_time] => 0.380074
            [connect_time] => 0.397038
            [pretransfer_time] => 0.494325
            [size_upload] => 256
            [size_download] => 106
            [speed_download] => 181
            [speed_upload] => 437
            [download_content_length] => -1
            [upload_content_length] => 256
            [starttransfer_time] => 0.585276
            [redirect_time] => 0
            [certinfo] => Array
                (
                )

            [redirect_url] =>
        )


and the response from GCM (i.e., the return from curl_exec()):

        (
            [multicast_id] => -1
            [success] => 1
            [failure] => 0
            [canonical_ids] => 0
            [results] => Array
                (
                    [0] => Array
                        (
                            [message_id] => fake_message_id
                        )

                )

        )
        HTTP status: 200

Martin Revert

unread,
Sep 24, 2012, 5:35:16 AM9/24/12
to andro...@googlegroups.com
Yes, that did the trick.
But documentation could be clearer, because by payload is not only intended as the query string.
It would be easy for developers and for easy test reasons if this could be sended as a name/value pair more inside the JSON object, like all the other parameters requested to GCM.

Just my two cents.
Martin

amrutha shanbhag

unread,
Dec 3, 2012, 4:54:40 AM12/3/12
to andro...@googlegroups.com
Hi,

I am using the Sender helper class from the GCM library to send GCM messages. And so not able to set the dry_run parameter for testing purpose. A setter in the Builder would be of help. As there is no other way out in this case.
Reply all
Reply to author
Forward
0 new messages