Keeping connection to APNs open on App Engine using Modules in Go - google-app-engine

I'm trying to implement iOS push notifications for a message board app I've written (so like notification for new message etc. etc.) but have no real idea where to start.
A lot the current documentation seems to be out of date in regard to keeping persistent TLS connections open to the APNs from App Engine and links to articles about deprecated backends. I'm using the Go runtime and just keep getting stuck. For instance, the creation of the socket connection to APNs requires a Context which can only be got from a HTTP request, but architecturally this doesn't seem to make a lot of sense because ideally the socket remains open regardless.
Is there any clearer guides around that I'm missing or right now is it a better idea to set up a separate VPS or compute instance to handle it?

I'm not that familiar with Go but if you cannot figure out how to connect to APNS in Go then I would recommend creating a separate Java Module that would be responsible for sending push notifications to APNS and a Task Queue to send 'hey-send-this-push-notification' messages (tasks) from Go to this Java Module. You could enqueue tasks from Go and process them in your Java Module.
There is an open-source, Java APNS library that you can use to send push notifications. It was specifically designed to work (and be used) on Google App Engine.
Backends are deprecated; use Modules:
https://developers.google.com/appengine/docs/java/modules/
https://developers.google.com/appengine/docs/go/modules/
Regarding enqueuing tasks:
https://developers.google.com/appengine/docs/java/taskqueue/
https://developers.google.com/appengine/docs/go/taskqueue/

Related

Firebase: How to awake App Engine when client changes db?

I'm running a backend app on App Engine (still on the free plan), and it supports client mobile apps in a Firebase Realtime Database setup. When a client makes a change to the database, I need my backend to review that change, and potentially calculate some output.
I could have my App Engine instance sit awake and listen on Firebase ports all the time, waiting for change anywhere in the database, but That would keep my instance awake 24/7 and won't support load balancing.
Before I switched to Firebase, my clients would manually wake up the backend by sending a REST request of the change they want to perform. Now, that Firebase allows the clients to make changes directly, I was hoping they won't need to issue a manual request. I could continue to produce a request from the client, but that solution won't be robust, as it would fail to inform the server if for some reason the request didn't come through, and the user switched off the client before it succeeded to send the request. Firebase has its own mechanism to retain changes, but my request would need a similar mechanism. I'm hoping there's an easier solution than that.
Is there a way to have Firebase produce a request automatically and wake up my App Engine when the db is changed?
look at the new (beta) firebase cloud functions. with that, you can have node.js code run, pre-process and call your appengine on database events.
https://firebase.google.com/docs/functions/
Firebase currently does not have support for webhooks.
Have a look to https://github.com/holic/firebase-webhooks
From Listening to real-time events from a web browser:
Posting events back to App Engine
App Engine does not currently support bidirectional streaming HTTP
connections. If a client needs to update the server, it must send an
explicit HTTP request.
The alternative doesn't quite help you as it would not fit in the free quota. But here it is anyways. From Configuring the App Engine backend to use manual scaling:
To use Firebase with App Engine standard environment, you must use
manual scaling. This is because Firebase uses background threads to
listen for changes and App Engine standard environment allows
long-lived background threads only on manually scaled backend
instances.

Best/Correct way to create a client-server constant listener

I am creating an app that involves sending and receiving settings... The desktop application is constantly sending information to a hosted MySQL database, and the Android app will query this same information. It is something similar to the whatsapp web (but in this case, I'll be using a desktop app instead of webpages).
Until this part, everything is working as I need... but, this same Android app will be used to send settings to the desktop app, and the desktop will read and change its settings according to what was just sent.
If I need to constantly query the hosted MySQL database and check if there is any kind of changes sent from the Android, I believe that I'll have a performance drop... each time a query loop is finished, I would have to query, check for any modifications and so on.
Is there a better or correct way to do this kind integration between two apps? I've read something about WebSockets, but I don't have much technical information about this, neither examples that I can use in this case.
Thank you very much for your knowledge sharing.
Here are some useful sites on WebSocket:
http://websocket.org
http://blog.kaazing.com/ [some useful blog posts]
http://www.html5rocks.com/en/tutorials/websockets/basics/
https://goo.gl/5OaJff [mozilla site]
You may want to consider the Observer/Observables pattern. The MYSQL is the Observable and your desktop app and Android app are Observers (and you can add other Observers in the future). Its a common pattern with lots of examples out there. But you'll need a centralized WebSocket server and an Observer/Observable coordination subsystem. You can setup a pub/sub message broker that uses WebSocket with a nice JMS, MQTT, etc, API to make your life easier. ActiveMQ, IBM MQ Lite, Kaazing JMS Edition... lots of options.
full disclosure. I work for Kaazing.

is there any way to make remote desktop client using channel API GAE?

I have read about Remote Desktop Client with AngularJS and Yeoman.It is using sockets internally.
http://blog.mgechev.com/2014/02/08/remote-desktop-vnc-client-with-angularjs-and-yeoman/
As my angular app is deployed on GAE and I have implemented channel API for notifications. So is there any way to use channel API for the same?
Or any other best way to do the same?
The simple answer is: No, the approach documented by the provided link will not work on "normal" app engine.
Here a couple of reasons:
It uses a continuous socket connection to connect to the VNC server
It uses server sockets* to provide a stream to Yeoman VNC
The Channel API is not an appropriate replacement for sockets
*) App Engine doesn't allow you to open listening sockets. Having the 60 second / 10 minute deadlines in place it wouldn't be practical anyway (unless manually scaled and thus taking all the good out of app engine)
I just wrote an extended answer on a slightly similar question here. Some of the points there could be of interest to you.
Consider using App Engine Managed VM. I believe you can also run node.js application on managed vms.

Using GAE channels without browser

I want to write GAE based application that synchronizes information between computers/phones. Right now I am only querying periodically, which causes delays or requires user to click a button to refresh manually.
With GAE channels, it should be possible to do it this way that a device can be notified when it should refresh. However, since I want it to be a desktop app (not web app), I am wondering if I can write my own client to channel API? Or grab whatever's out there.
Is the protocol documented or are there clients available for anything other than JS?
The only official interface is the Javascript client library. Although you could reverse-engineer how it works, since it's not a documented part of the interface, it could change at any time without notice.
If you're interfacing with Android phones or iPhones, each of them has a 'push' messaging API that you could use (Cloud to Device Messaging for Android, and Push Messaging for iPhone).
There is now a Java implementation for the Channels API. It was just released days ago and is available via git at https://github.com/gvsumasl/jacc. I've also taken the liberty of forking it and providing a mavenized version at https://github.com/hatboyzero/jacc.

IM service using Google App Engine

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.

Resources