google-app-enginechannel-api

Access GAE channel API on remote server


Is there some way to establish a channel (Channel API) with a GAE server which is not the origin of the current HTML?

Before really starting to work with this, I thought I could connect to a remote Channel API server by simply using an absolute URL in the included script tag:

<script type="text/javascript" src="http://localhost:8080/_ah/channel/jsapi"></script>

But this does not work. When trying to open the channel, I just get the local index.html returned (btw, the local web server is a webpack-dev-server on port 8090).

The Channel API contains no mention of specifying a URL on creation of channel.

I deliberately do not want to let my html/js app be hosted by the appengine, because I prepare for packaging with Cordova/Phonegap. This means that the remote GAE server must be able to act as a pure API server for my mobile app.


Solution

  • Turns out this is not intendend to work like I wanted. The javascript for initializing the Channel API must be downloaded from the server to which you want to connect.

    I decided to not use the Channel API, but instead use HTML5's EventSource - but this is not possible towards apps on GAE because of the restrictions on how long connections are allowed to be kept open. So I have now moved the whole app out of GAE and hosting it in a Spring Boot application. This was a good option for me, and I have not regretted it for even a second. But for others, it might not be so easy to move out of GAE.