0
votes

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.

1
There is a fair amount of magic in the channel API and you don't get choices like that. Perhaps consider native websockets on a VM linked to your appl.Paul Collingwood
Yes, Paul - it seems so. That was actually a nail in the coffin for my GAE plans.Leif John
I have an app that uses a Compute VM as a socket server for reasons similar to this, talking to a GAE app. So it can be worked around, and you get more options then also.Paul Collingwood

1 Answers

0
votes

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.