I open a channel during the app initialization through a series of ajax calls:
getToken = function () {
xhr = new XMLHttpRequest();
xhr.open("GET", "/game?action=getChannelToken", true);
xhr.send(null);
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status==200) {
connect(xhr.responseText);
}
};
};
Servlet:
ChannelService channelService = ChannelServiceFactory.getChannelService();
channelToken = channelService.createChannel(uid);
The token is then returned to the javascript for:
connect = function (token) {
// alert ("connect");
var channel = new goog.appengine.Channel(token);
var socket = channel.open();
socket.onopen = onOpened;
socket.onmessage = onMessage;
socket.onerror = onError;
socket.onclose = onClose;
};
I'm getting this error:
WARNING: /_ah/channel/dev com.google.appengine.api.channel.dev.LocalChannelFailureException: Channel for application key null not found.
The channel creation part is very simple, so I do not understand where is the problem.
System.out.println (channelToken);
returns something like
channel--rrmk8i-100002139544068
(100002139544068 is the uid I used to create the channel), so it seems to return a real token. Moreover, channelService.sendMessage(msg);
(using the same uid as before), sends the message without any problem.
Does anyone have any idea why this is happening? I'm using eclipse 3.5.2, GAE/J 1.4.2 and ubuntu 10.10
Googling for that exception I found only one discussion here: http://groups.google.com/group/google-appengine-java/browse_thread/thread/19f250b1ff0e4342
but changing var channel = new goog.appengine.Channel(token);
to var channel = new goog.appengine.Channel(uid);
did not solve anything (and, from what I understand, it shouldn't)