Google CCS Server implementation for GCM (Google Cloud Messaging)

1,625 views
Skip to first unread message

Amit Sangani

unread,
Aug 14, 2013, 5:00:51 PM8/14/13
to google-a...@googlegroups.com
I took the first shot at implementing the new GCM CCS server on GAE using the Smack library for XMPP. Here is more documentation - https://developer.android.com/google/gcm/ccs.html

However, I got below exceptions. I do have smack.jar, smackx.jar in WEB-INF/lib directory (although only smack.jar is required).

[s~mighty-app/0-58.369479717923256319].<stderr>: Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.LastActivityManager
[s~mighty-app/0-58.369479717923256319].<stderr>: Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.commands.AdHocCommandManager
Error for /client
java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details.
	at com.google.appengine.runtime.Request.process-0046d50b9de5cb22(Request.java)
	at javax.naming.InitialContext.<clinit>(InitialContext.java)
	at org.jivesoftware.smack.util.dns.JavaxResolver.<clinit>(JavaxResolver.java:45)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:111)
	at org.jivesoftware.smack.SmackConfiguration.parseClassToLoad(SmackConfiguration.java:335)
	at org.jivesoftware.smack.SmackConfiguration.<clinit>(SmackConfiguration.java:95)
	at org.jivesoftware.smack.Connection.<clinit>(Connection.java:125)
	at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfiguration.java:78)
	at com.xmpp.test.GcmXmppSender.connect(GcmXmppSender.java:243)
...
On further investigation, I found that XMMP client implementation on GAE server requires a socket to be opened. There is a way to open a socket from GAE using Open Socket API - https://developers.google.com/appengine/docs/python/sockets/overview
However my question is, do we need to implement XMPP client library from scratch? Or has anybody used a XMPP client library on GAE server successfully? 

I am sure lot of developers are interested in this answer.

Vinny P

unread,
Aug 14, 2013, 5:13:33 PM8/14/13
to google-a...@googlegroups.com
On Wed, Aug 14, 2013 at 4:00 PM, Amit Sangani <amit.s...@gmail.com> wrote:
I took the first shot at implementing the new GCM CCS server on GAE using the Smack library for XMPP. Here is more documentation - https://developer.android.com/google/gcm/ccs.html
 
However my question is, do we need to implement XMPP client library from scratch? Or has anybody used a XMPP client library on GAE server successfully? 

 
Are you trying to implement a server or a client? A client is easy, but you can't implement a XMPP server  on GAE since the Sockets API only does outgoing sockets, not inbound.
 
Smack is not intended to be used in servers, it's an XMPP client.

On Wed, Aug 14, 2013 at 4:00 PM, Amit Sangani <amit.s...@gmail.com> wrote:
However my question is, do we need to implement XMPP client library from scratch? Or has anybody used a XMPP client library on GAE server successfully? 
 
 
There is already an implementation of an XMPP client on GAE: https://developers.google.com/appengine/docs/java/xmpp/
 
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 
 

amits

unread,
Aug 14, 2013, 7:48:44 PM8/14/13
to google-a...@googlegroups.com
Thanks Vinny for your reply.

I want to implement a XMPP client on GAE which connects to Google's Cloud Connection Server (CCS) based on this documentation - https://developer.android.com/google/gcm/ccs.html (see the Java Sample using the Smack library). This client needs to maintain a bi-directional, asynchronous persistent connection with CCS server. 

I am unable to execute a smack xmpp client because of GAE's sandbox restrictions.

I don't think you can connect to CCS using the XMPP api you pointed out, but not 100% sure.

On Wednesday, August 14, 2013 2:13:33 PM UTC-7, Vinny P wrote:

I took the first shot at implementing the new GCM CCS server on GAE using the Smack library for XMPP. Here is more documentation - https://developer.android.com/google/gcm/ccs.html
 
However my question is, do we need to implement XMPP client library from scratch? Or has anybody used a XMPP client library on GAE server successfully? 

 
Are you trying to implement a server or a client? A client is easy, but you can't implement a XMPP server  on GAE since the Sockets API only does outgoing sockets, not inbound.
 
Smack is not intended to be used in servers, it's an XMPP client.

Vinny P

unread,
Aug 14, 2013, 11:11:41 PM8/14/13
to google-a...@googlegroups.com
On Wed, Aug 14, 2013 at 6:48 PM, amits <amit.s...@gmail.com> wrote:
Thanks Vinny for your reply.
I want to implement a XMPP client on GAE which connects to Google's Cloud Connection Server (CCS) based on this documentation - https://developer.android.com/google/gcm/ccs.html (see the Java Sample using the Smack library). This client needs to maintain a bi-directional, asynchronous persistent connection with CCS server. 

I am unable to execute a smack xmpp client because of GAE's sandbox restrictions.
 
 
There's no way to get around the sandbox restrictions.
 
If you need to run the smack xmpp library the best way is to get a Compute Engine machine ( https://cloud.google.com/products/compute-engine ), run the XMPP client on that, and then run the rest of your application on App Engine. You can communicate to the Compute Engine machine via http requests.
 
You can also try using Compute Engine backends: https://groups.google.com/forum/#!topic/google-appengine/gRZNqlQPKys
Message has been deleted

Vinny P

unread,
Sep 11, 2013, 2:32:05 PM9/11/13
to google-a...@googlegroups.com
On Tue, Sep 10, 2013 at 11:29 AM, mick <michae...@smartpm.com> wrote:
So is it that the suggested Smack is just using unnecessary features which conflicts with GAE restrictions, or is it not possible at all to deploy a XMPP client on GAE?



You can deploy an XMPP client on GAE, that's documented here: https://developers.google.com/appengine/docs/java/xmpp/

You just can't run the Smack XMPP library because it requires certain classes that are not allowed in the App Engine sandbox.

Devwrat Lad

unread,
Apr 15, 2014, 2:22:08 AM4/15/14
to google-a...@googlegroups.com
Still Goole app Engine dont support java smack library now ?

Vinny P

unread,
Apr 24, 2014, 1:16:44 PM4/24/14
to google-a...@googlegroups.com
On Tue, Apr 15, 2014 at 1:22 AM, Devwrat Lad <devwr...@gmail.com> wrote:
Still Google app Engine dont support java smack library now ?


Smack uses certain classes that aren't included on the App Engine JRE whitelist, so no you can't run Smack at the moment. If you do need to run Smack I would suggest looking into Managed VMs ( https://developers.google.com/cloud/managed-vms ) where you have more freedom to run applications, but still keeping access to App Engine resources.

Nick

unread,
Dec 5, 2014, 4:26:09 AM12/5/14
to google-a...@googlegroups.com
Can I connect to a GCM Cloud Connection Server with that client? Will the connection be bidirectional?

Vinny P

unread,
Dec 8, 2014, 1:59:09 AM12/8/14
to google-a...@googlegroups.com
On Fri, Dec 5, 2014 at 3:26 AM, Nick <domeni...@gmail.com> wrote:
Can I connect to a GCM Cloud Connection Server with that client? Will the connection be bidirectional?


My understanding is that it doesn't work (at least, it didn't work a year ago). See here for details: http://stackoverflow.com/questions/16616719/gcm-xmpp-on-appengine

If you want to connect to GCM, you'll need to use the regular HTTP endpoints.


-----------------
-Vinny P
Technology & Media Consultant
Reply all
Reply to author
Forward
0 new messages