does the channel api work across domains?

570 views
Skip to first unread message

Chad Burt

unread,
Dec 3, 2010, 1:16:57 PM12/3/10
to google-a...@googlegroups.com
Say I have an application hosted outside of appengine. I'd like to build a chat app hosted on appengine to take advantage of the channel API. Can I use that system from the first app on a different domain? If so, will it work on all browsers, or just those that support the crossdomain access control header?
Thanks,
-Chad

P. Petrov

unread,
Dec 3, 2010, 1:24:30 PM12/3/10
to google-a...@googlegroups.com
You can. The Channel API is designed to workaround the JavaScript same-origin policy, and will work across domains.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Chad Burt

unread,
Dec 3, 2010, 1:27:13 PM12/3/10
to google-a...@googlegroups.com
That is great news! Thanks

--
-Chad

sidepodcast

unread,
Dec 10, 2010, 1:53:03 PM12/10/10
to Google App Engine
any idea how to get cross-domain working in development mode? the base
url appears to be a fixed string.

ta.


On Dec 3, 6:24 pm, Peter Petrov <onest...@gmail.com> wrote:
> You can. The Channel API is designed to workaround
> the JavaScript same-origin policy, and will work across domains.
>
>
>
> On Fri, Dec 3, 2010 at 8:16 PM, Chad Burt <underbluewat...@gmail.com> wrote:
> > Say I have an application hosted outside of appengine. I'd like to build a
> > chat app hosted on appengine to take advantage of the channel API. Can I use
> > that system from the first app on a different domain? If so, will it work on
> > all browsers, or just those that support the crossdomain access control
> > header <http://www.w3.org/TR/cors/>?
> > Thanks,
> > -Chad
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-a...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
> > .

sidepodcast

unread,
Dec 10, 2010, 9:21:31 PM12/10/10
to Google App Engine
ended up using live to develop with.

am disappointed with the channel api implementation. for some reason
calling it causes huge cpu usage and there's no ability to broadcast
to all connected clients. ahh well.

Kristopher Giesing

unread,
Oct 23, 2012, 2:15:02 AM10/23/12
to google-a...@googlegroups.com
The live version uses an embedded iFrame.  The dev server version can't work across domains without modifications, but I have gotten it to work by adding a method that overrides the base URL.

- Kris

On Monday, October 22, 2012 2:27:28 PM UTC-7, niedbalski wrote:
Hello Chard ...

The big question here is HOW ?

niedbalski

unread,
Oct 24, 2012, 5:10:20 PM10/24/12
to google-a...@googlegroups.com
Hi Kristopher,

On Tuesday, October 23, 2012 3:15:02 AM UTC-3, Kristopher Giesing wrote:
The live version uses an embedded iFrame.  The dev server version can't work across domains without modifications, but I have gotten it to work by adding a method that overrides the base URL.

- Kris

On Monday, October 22, 2012 2:27:28 PM UTC-7, niedbalski wrote:
...


Do you know why the development server is not using the same iframe work-around ?  Can you share your hack for this?

Thanks you.

JNR.



Kristopher Giesing

unread,
Oct 27, 2012, 1:48:26 PM10/27/12
to google-a...@googlegroups.com
I added a function like this to the channel javascript:

goog.appengine.DevSocket.setConnectionBase = function(base) { goog.appengine.DevSocket.BASE_URL = base + "_ah/channel/"};


...

goog.exportSymbol("goog.appengine.Channel.setConnectionBase", goog.appengine.DevSocket.setConnectionBase);


This allowed me to serve the channel javascript as a static file served outside of appspot.com instead of through the normal page load process. (This is a static mobile app based on PhoneGap.) The base URL I set to was the appspot.com domain.

- Kris

Kristopher Giesing

unread,
Oct 27, 2012, 1:52:55 PM10/27/12
to google-a...@googlegroups.com
Sorry, check that, for development I set the connection base to the equivalent of localhost.  I also added the same methods to the prod version of the channel JS, which was trickier because it's minified.

This works for me because cross domain restrictions don't apply to statically served files, at least on iOS devices.  Your use case may be different.

- Kris

Kristopher Giesing

unread,
Oct 28, 2012, 4:53:26 PM10/28/12
to google-a...@googlegroups.com
As an addendum to this... I am migrating off the channel API.  I did some testing today with enough logging in place to prove that the channel API was silently failing to deliver messages to connected clients.  Given all the other problems, this was the straw that broke the camel's back.

Since I already have a node.js instance standing by to deliver Apple push notifications, I'm going to expand that instance's role to handling connected message transport as well.  I'm planning to use socket.io to do this.  I should be able to do this in such a way that it's largely transparent to the client, abstracted behind a class that knows how to connect to the messaging service and fan out resulting messages.  If people are interested I'll post the solution somewhere when it's done.

- Kris

puriketu99

unread,
Jun 25, 2013, 1:26:00 PM6/25/13
to google-a...@googlegroups.com
Hi Kris

Thanks for your hack but my js file does not work.My js file is as following.
If you notice my mistake,Please tell me it.

-puriketu99

2012年10月28日日曜日 2時48分26秒 UTC+9 Kristopher Giesing:

yngling

unread,
Jun 27, 2014, 8:15:14 AM6/27/14
to google-a...@googlegroups.com
I am having a hard time making channels work with an api module and a web (www) module... has anyone tried this lately?

/Alexander
Reply all
Reply to author
Forward
0 new messages