GCM returns "Unavailable"

1,221 views
Skip to first unread message

sparkgene

unread,
Jun 29, 2012, 4:33:25 AM6/29/12
to androi...@googlegroups.com
I'm working on migrate to gcm.

Using gcm.jar to get the registration id is successfully done.
Sending the message to gcm endpoint returns HTTP Status 200.

But the result contains error => Unavailable.

In the GCM document(http://developer.android.com/guide/google/gcm/gcm.html) this error solution is "If it is Unavailable, you could retry to send it in another request."

Do anyone have information about this error?


Monnand

unread,
Jun 29, 2012, 6:04:10 PM6/29/12
to androi...@googlegroups.com
I have exactly the same issue.

No matter how many time I tried, it keep receiving "unavailable" error.

Have you had any solution on that now?

Regards,
-Monnand

Felipe Leme

unread,
Jun 29, 2012, 6:04:52 PM6/29/12
to androi...@googlegroups.com
Did you get it just once or did you get it again when you retried?

Usually, you get an 'Unavailable' when the server could not process one message in the multicast, in which case you should try again. But if you're always getting that error, it might be caused by something else that we would have to investigate.

Notice that if you use the Sender class from the gcm-server.jar, it has logic to automatically retry.

Monnand

unread,
Jun 29, 2012, 6:36:29 PM6/29/12
to androi...@googlegroups.com
Hi Felipe,

I got it every time I retried. I am using my own code. Is it possible that I got unavailable error because of the error on my side? (According to documents, it should not be possible.)

Here is the result I received:

{"multicast_id":5030400576422639801,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"Unavailable"}]}

Thank you!

Regards,
-Monnand

Felipe Leme

unread,
Jun 29, 2012, 6:44:49 PM6/29/12
to androi...@googlegroups.com
Your code should be fine, but there might be something wrong on our side that we need to investigate.

What's your package name? (you can answer me in private, if you prefer)

Monnand

unread,
Jun 29, 2012, 6:53:54 PM6/29/12
to androi...@googlegroups.com, andro...@googlegroups.com
I think it would be better to cc to android-gcm group. I have already corrected the code --- It seems like a bug on GCM side.

Here is the message I sent causing "unavailable error"
{"registration_ids":["SOME REG ID"],"collapse_key":"c058391ee54cec4b8812ab121411afbaf6de024a","data":{"msg":"Hello World"},"delay_while_idle":false,"time_to_live":4294967295}

Here is the message I sent without problem:
{"registration_ids":["SOME REG ID"],"data":{"msg":"Hello World"}}

Then I thought it might be the value of time_to_live field is too large. So I tried this:

{"registration_ids":["APA91bHaWwM9ytxfHVBjHZTtQ7Ggw_rovTOYFMzhi5ae-gLySoejokMpBx9krhynlYj_9kG2d3rg7C5carlybQcfIiIlIho4MR1AjWJIhk45SJ4mMFWP038KUP5THTZtVsuAPicio54IRqjSMgCNy9TgOdZAL_toow"],"collapse_key":"67ab7e1dae275e389c9fbc323b68a2b568962294","data":{"msg":"Hello World"},"time_to_live":4294967295}

And I got unavailable; but the following data could be sent.

 {"registration_ids":["APA91bHaWwM9ytxfHVBjHZTtQ7Ggw_rovTOYFMzhi5ae-gLySoejokMpBx9krhynlYj_9kG2d3rg7C5carlybQcfIiIlIho4MR1AjWJIhk45SJ4mMFWP038KUP5THTZtVsuAPicio54IRqjSMgCNy9TgOdZAL_toow"],"collapse_key":"1c2ded740aca18f2148fec0a78e9a1a57526440e","data":{"msg":"Hello World"},"time_to_live":120}

Would you please check if I am correct? It might be better if set time_to_live to the default value if the value in the request is too large.

Regards,
-Monnand

Monnand

unread,
Jun 29, 2012, 6:57:18 PM6/29/12
to androi...@googlegroups.com, andro...@googlegroups.com
Oops. I forgot to remove my registration ID. Anyway, it just a test device with nothing valuable data. Please ignore it.

Sorry about that.

Regards,
-Monnand

francesco nerieri

unread,
Jun 29, 2012, 7:46:34 PM6/29/12
to androi...@googlegroups.com, andro...@googlegroups.com
Monnand,

we do set the value to 4 weeks if the number is bigger than that,
however if the number is too big (you can write all the digits you
like) than we do invalidate the request.

We definitely need to return a better error code for this case and we
are already working on it. We will also update the documentation
accordingly.

Thanks for pointing this out,
f

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

Francesco Nerieri

unread,
Jun 29, 2012, 7:53:52 PM6/29/12
to andro...@googlegroups.com, androi...@googlegroups.com

Monnand

unread,
Jun 29, 2012, 11:21:28 PM6/29/12
to andro...@googlegroups.com, androi...@googlegroups.com
Hi Francesco,

Thanks for your reply. I can see all you guys are working hard on this project. Really appreciated.

As you mentioned, it might be better to return another error code on this situation. I think I was lost in this document before.

Regards.
-Monnand

Jun Ichikawa

unread,
Jun 30, 2012, 11:43:15 AM6/30/12
to andro...@googlegroups.com, androi...@googlegroups.com
Thanks for the reply.

I think the problem is resolved in this.

Regards
Jun


2012/6/30 Monnand <mon...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "android-gcm" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-gcm/-/0s3OLbrAzFMJ.
>
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-gcm...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-gcm?hl=en.

Thao Phi Dinh

unread,
Jul 3, 2012, 12:13:02 AM7/3/12
to androi...@googlegroups.com, andro...@googlegroups.com
I have used cURL php
Here is my code:
 
        $json['data'] = $data;
        $json['registration_ids'] = array($registrationId);
        $json['collapse_key'] = $collapseKey;
        $json['delay_while_idle'] = false;
        $json['time_to_live'] = 100;
        
        $headers = array(
            'Content-Type:application/json',
            'Authorization:key=' . GOOGLE_API_KEY
        );
        

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $gcmUrl);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_POST, TRUE);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json));
        $response = curl_exec($curl);
        curl_close($curl);

Result: 
{"multicast_id":6086117185750372243,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"Unavailable"}]}


Thank for reply!

JonathanC

unread,
Jul 5, 2012, 9:14:24 AM7/5/12
to andro...@googlegroups.com, androi...@googlegroups.com
I resolved this, obviously you also receive 'Unavailable' if an app hasn't registered with a senderid yet.

Woot, a working python gcm sender :-)

On Wednesday, July 4, 2012 10:05:59 AM UTC+2, JonathanC wrote:
After making the encoded json data somewhat closer to the sample on http://developer.android.com/guide/google/gcm/adv.html :

{"delay_while_idle": true, "collapse_key": "Event", "time_to_live": 86400, "registration_ids": ["<mykey>"], "data": {"message": "Testing"}}

I'm still getting 'Unavailable' ... any news on this issue? :)

On Wednesday, July 4, 2012 9:50:02 AM UTC+2, JonathanC wrote:
Hey guys,

I'm experiencing similar issues:

2012-07-04 09:45:04+0200 [-] Sending: {"data": {"message": ["c\u00e6mera 7318952 - is nu online en klaar voor gebruik"]}, "registration_ids": ["<mykey>"]}
2012-07-04 09:45:04+0200 [-] AndroidNotificationSender:send:120 Sent.
2012-07-04 09:45:04+0200 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] [Droid] Message transmit response:
2012-07-04 09:45:04+0200 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] {"multicast_id":7938595614873647090,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"Unavailable"}]}
2012-07-04 09:45:04+0200 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Finished  
2012-07-04 09:45:04+0200 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] [Droid] Message transmit response:
2012-07-04 09:45:04+0200 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] {"multicast_id":7614338315620730041,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"Unavailable"}]}
2012-07-04 09:45:04+0200 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Finished 

Did I encode the data incorrectly?

Friendly greetings,
    Jonathan

Christian Carnero

unread,
Jul 5, 2012, 11:16:17 AM7/5/12
to androi...@googlegroups.com, andro...@googlegroups.com
Hi JonathanC!
Im trying to make this work but I always receive the "200 + ´Unavailable´" message 

I read this and I want to know what do you mean when you mention "if an app hasn't registered with a senderid yet."?

regards
Christian

Thao Phi Dinh

unread,
Jul 5, 2012, 11:23:00 AM7/5/12
to androi...@googlegroups.com, andro...@googlegroups.com
Thank's !
I trying.

JonathanC

unread,
Jul 24, 2012, 2:02:34 PM7/24/12
to androi...@googlegroups.com, andro...@googlegroups.com

Venkateswara Rao Repalle

unread,
Jul 28, 2012, 3:55:06 PM7/28/12
to androi...@googlegroups.com

Jasvir

unread,
Sep 6, 2012, 11:38:52 AM9/6/12
to androi...@googlegroups.com
Can some one help me on 401.I am getting following error while trying to send message. Device is registered successfully but i am not able send notifications:

com.google.android.gcm.demo.server.InvalidRequestException: HTTP Status Code: 401()
	com.google.android.gcm.demo.server.Sender.sendNoRetry(Sender.java:184)
	com.google.android.gcm.demo.server.Sender.send(Sender.java:121)
	com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServlet.java:84)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.

Amit Patoliya

unread,
Sep 10, 2012, 2:58:19 AM9/10/12
to androi...@googlegroups.com
i will also getting same error
but when you try jetty its works fine....
Reply all
Reply to author
Forward
0 new messages