Channel API broken in Chrome Extensions

138 views
Skip to first unread message

RSW

unread,
Feb 10, 2011, 1:08:07 PM2/10/11
to google-a...@googlegroups.com

Over Christmas I implemented some code to open a channel to my App Engine application in a Chrome extension using the channel API and it was working fine.

I recently returned to the code and find that it is broken, and the problem seems to lie in the URL to the talkgadget that the client code is trying to load into a frame.

I took a snapshot of the code returned by /_ah/channel/jsapi on December 21 and I am comparing it to today's code.

When the older version tried to get talkgadget.google.com/talkgadget/d?token=[my-token] it was hardcoded to use http. Sensibly enough, the code was later changed to check the page's protocol in document.location and adapt to cases where https is used. The problem now is that when running in a chrome extension it grabs chrome-extension: as the protocol and naturally the channel fails to open in the extension.

Setting the base of the background page to my appspot URL does not change document.location, although I had some vague notion that it should. (Not sure what the standards say.)

Is there a workaround for this? One thought was to create my own iframe loaded from my site, but then it will nest the actual channel iframe, complicating things. 

I wonder if Moishe or someone else on the App Engine team could comment on this. It seems like the this is a bug and the code should take into chrome extensions either by testing for the protocol and searching for a base tag as an alternative, or provide some way to configure this through the javascript object.

Ikai Lan (Google)

unread,
Feb 10, 2011, 1:57:24 PM2/10/11
to google-a...@googlegroups.com, RSW
There's an issue with the Channel API that we're working to address. It's not an issue with your code.

--
Ikai Lan 
Developer Programs Engineer, Google App Engine



--
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.

RSW

unread,
Feb 10, 2011, 2:26:02 PM2/10/11
to google-a...@googlegroups.com, RSW
Thanks, Ikai. Does a fix depend on releasing an update to GAE or will you separately update channel.js when you have a fix? Isn't channel.js code shared with  Google Talk?

I suppose I could ask you for ETA, but I'm guessing you're not at liberty to say.... soon would be awfully nice. Luckily I do not have code in production for end users yet, in which case this would be critical.

-Ronald

RSW

unread,
Apr 13, 2011, 11:23:34 PM4/13/11
to google-a...@googlegroups.com, RSW
Ikai, this got fixed not too long after you posted, and has been working fine for many weeks now.

However, this evening I started having problems with the Channel API again.

Unlike the last time,where an exception was thrown because the TalkGadget was embedded in a Chrome extension,  the channel object is created without throwing an exception. But none of the channel events fire, not onopen, not onerror, not onclose. I also don't see any persistant connection open, as I did before. The object returned has a readyState of 0, which I assume is probably bad. I also just noticed in the log the error message "Unsafe JavaScript attempt to access frame with URL ... Domains, protocols and ports must match" which usually occurs when the channel expires and the JS in the talkgadget iframe tries to access its container. All the same, none of the usual subsequent events fired to allow the code to get a new token.

Did something change recently (like today)? Certainly something has changed in the month since I capture a SHA-1 digest of the talkgadget channel file.

I have run 

        curl http://talkgadget.google.com/talkgadget/channel.js | openssl sha1 

every once and a while because I have no idea how to otherwise track changes that might affect my extension. Signature on 2011-03-16T12:35 GMT+04:00 was 222ea9104664e31a10a862624c938b4fb41ef556, and is 75ff42592bc0ecc86d3d03b11611a54908aa72e9 as of 2011-04-13T20:26 GMT+04:00. So there must have been a release in that time. Any ideas?

So, I wonder if you can help track down what if any change may have occurred that is causing problems with the Channel API or point me in the direction of revision history from whomever is making changes

I need to be able to rely on this API, but it doesn't seem to be quite there yet.

-Ronald.


Moishe

unread,
Apr 14, 2011, 9:37:26 AM4/14/11
to Google App Engine
Hi, Ronald. I'm looking into this today, will try to get back to you
later on with some more information.

Is this only happening with Chrome extensions? Which channel of Chrome
are you running - dev, beta or main?

Thanks!

-Moishe

RSW

unread,
Apr 14, 2011, 10:41:45 AM4/14/11
to google-a...@googlegroups.com
Hi Moishe,

I am using the stable release,  and the current up-to-date version is 10.0.648.204 (on a Mac). 

I only use the Channel API within a chrome extension, so I can't say if there's a problem in other cases.

-Ronald.

elias_naur

unread,
Apr 14, 2011, 11:09:16 AM4/14/11
to Google App Engine
I have the same problem here, trying to use an App Engine Channel from
a Chrome extension fails to trigger onmessage/onopen/onerror. Nothing
happens, and there's nothing in the extension background page console
log. It worked fine a few days ago, and I haven't changed any
extension code in that time.

Chrome: 10.0.648.204 (stable) on Ubuntu 10.10

- elias

Moishe

unread,
Apr 14, 2011, 4:51:13 PM4/14/11
to Google App Engine
Okay, I've identified and fixed the problem, and am working on getting
a fix rolled out to production. No ETA on that yet.

In the meantime if you'd like a patched jsapi file that you can serve
statically from your own site, contact me directly at moishel at
google.com.

RSW

unread,
Apr 14, 2011, 5:11:41 PM4/14/11
to google-a...@googlegroups.com
Moishe,

Glad to hear it and thanks for the quick follow-up. I'll send you an email shortly for the static file.

I wonder, is it generally possible/wise to use a static file in order to ensure predictable reliability? I.e. as with jquery served from the Google Libraries API, I can get the version I know works for me and upgrade after testing the change.

In any case, is there any way I can track changes in Gtalk like I can track them for GAE? The big weakness with Channel API seems to be the black box that is the GTalk infrastructure and the fact that it seems to update out-of-sync with GAE. How can issues like this be prevented in the future?

Thanks!

-Ronald.
Reply all
Reply to author
Forward
0 new messages