I do not think there's a way to do this but I thought I'd ask to see what workarounds people are using to avoid polling on Heroku and/or GAE.
How are you sending out notifications in somewhat real-time from these apps?
GAE can use one of the following to notify another system:
xmpp
urlfetch to a callback url
like to pubsubhubbub
send email
With Heroku's new Cedar stack you can do long polling.
There's a link to some long polling example code here.
As #dar mentions, you can use PubSubHubbub to do realtime notification without polling. Nick Johnson has an excellent tutorial on using an existing PubSubHubbub server, or even including a server with your application.
This will let you publish feeds and subscribe to them in realtime without polling.
Related
I've been experimenting with Google App Engine for the past few months. It's really easy to use, but it's just so limited what you can do. Namely, I can't use WebSockets or send Apple Push Notifications. Is DynamoDB the same way, that is I can't run "custom" code with it? Will I be able to use WebSockets or say run an XMPP server on it? I'm not entirely sure how that works with DynamoDB.
Well, DynamoDB is only a (lean) database engine. It will store your data but won't run anything beside queries. If you need a general purpose server, you can have a look at EC2.
App Engine does have an XMPP service: https://developers.google.com/appengine/docs/python/xmpp/ and https://developers.google.com/appengine/docs/java/xmpp/overview
Not that this'll help with Web Sockets or Apple Push Notifications.
The Channel API can be used provide persistent client connections: https://developers.google.com/appengine/docs/python/channel/overview
https://developers.google.com/appengine/docs/java/channel/
You can use AWS Lambda (Custom code) in conjunction with DynamoDB.
use case: 5 - 30 users simultaniously on a chat.
is it a good idea / is it possible to code this on google app engine?
Until the Channel API is released, you'll have to use polling to do this. When that API is released, App Engine will be (IMO, caveat that I work on the team) a great tool for this.
Note that with 1.3.6 you can use the Channel API for local development so you can at least get started implementing something, though it won't work in prod.
maybe it's a stupid question, but couldn't the GAE Application forward incoming messages to all known clients when they are posted to the server?
Why would that not work?
Laures
I would like to write a client application for Android that uses the Google App Engine as a database backend. My Android client would connect to the App Engine to save information, then it would connect later for reports. Is it possible to use the App Engine as a backend like this?
If you're looking for something like the remote api that the App Engine has in python, then you'll be disappointed to find it missing in Java.
That said, absolutely nothing stops your from hitting your app and posting data either through POST / JSON / XML / any other format you can think of. The same thing goes for getting your reports back.
If security is a concern, the OAuth protocol allows you to authenticate to app engine from your android device.
This is an aside, but as far as reporting is concerned, you might not find the app engine a very suitable platform for reporting type apps. Just make sure you understand its limitations - the lack of joins, 1000 object limit, no sum / average, necessary indexes, etc. It's certainly not impossible, but do think carefully about how you're going to model your data.
Yes, it is possible.
Without more details in your question, any more details in the answer would be speculation.
Yes, its very much possible. It's something I am also currently working on.
My code uses HTTP GET and HTTP POST and I am using a RESTful service on the GAE.
I'm sorry I can't provide any code because I am still learning however the library I'm using is called RESTLET. They have libraries for both GAE and Android however I'm only using RESTLET on the GAE and I'm just using the HTTP library in the Android SDK for the client.
http://www.restlet.org/
The version you require is 2.0 M6 and not the stable release.
No.
In your response to Laurence, you said you want a direct DB connetion. A client cannot connect directly to the GAE datastore. You must write web handlers to interface between the client and your data. It doesn't have to be much, but it must be something.
Yes, it is very possible. You would not connect directly to the GAE database though. A better architecture would be to make your app hit a URL that writes to the DB. For example, you could set up a Struts 2 action that takes the values of your query parameters and then mutates and validates them as necessary before persisting them.
I want to implement a web-based IM service on the lines Meebo. Might sound ambitious but that adds to the fun of it.
My research suggests XMPP would be a good protocol for the IM since it can talk to proprietary protocols as well. Am I right? What else would I need to complete this?
Could Google App Engine(GAE) fit in to this project? Can GAE be used to create and host the whole service? That would simplify matters significantly.Also,GAE does support XMPP.
I know what I want to make, need to know the best way to make it.
Thanks!
Suvir
GAE has an XMPP API that lets your app send and receive XMPP messages. The real sticking point with making a real time chat app using only GAE is that you can't push updates to the client. So your client would have to continually poll the server to see if there were any new messages. One way around this is to operate a comet server outside of GAE to forward the pushes to the client.
wikipedia page on comet techniques
Google App Engine allows you to use stateless HTTP requests and XMPP, but not TCP sockets. Thus you're limited to any IM services which use the former.
For an example of using the XMPP service, see Using the XMPP service:
For our example app, we're going to
write the Amazing Crowd Guru. The
Amazing Crowd Guru is a veritable
oracle, who can answer any question
you might pose it over XMPP. Writing
an omniscient computer program is no
small task, but thanks to a little
behind-the-scenes trickery, we're
going to get our users to do all the
work of answering questions for us.
The Twitter streaming api says that we should open a HTTP request and parse updates as they come in. I was under the impression that Google's urlfetch cannot keep the http request open past 10 seconds.
I considered having a cron job that polled my Twitter account every few seconds, but I think Google AppEngine only allows cron jobs once a minute. However, my application needs near-realtime access to my twitter #replies (preferably only a 10 second or less lag).
Are there any method for receiving real-time updates from Twitter?
Thanks!
Unfortunately, you can't use the urlfetch API for 'hanging gets'. All the data will be returned when the request terminates, so even if you could hold it open arbitrarily long, it wouldn't do you much good.
Have you considered using Gnip? They provide a push-based 'web hooks' notification system for many public feeds, including Twitter's public timeline.
I'm curious.
Wouldn't you want this to be polling twitter on the client side? Are you polling your public feed? If so, I would decentralize the work to the clients rather than the server...
It may be possible to use Google Compute Engine https://developers.google.com/compute/ to maintain unrestricted hanging GET connections, then call a webhook in your AppEngine app to deliver the data from your compute engine VM to where it needs to be in AppEngine.