我通過一系列的Ajax調用的打開應用程序初始化過程中的信道:即使消息通過,GAE/J Channel API異常?
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);
令牌,然後返回到的javascript:
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;
};
我得到這個錯誤:
WARNING: /_ah/channel/dev com.google.appengine.api.channel.dev.LocalChannelFailureException: Channel for application key null not found.
渠道創建部分非常簡單,所以我不明白問題出在哪裏。 System.out.println (channelToken);
回報像
channel--rrmk8i-100002139544068
(100002139544068是我用來創建頻道的UID),因此它似乎返回一個真正的象徵。此外,channelService.sendMessage(msg);
(使用與以前相同的uid),發送消息沒有任何問題。
有沒有人知道爲什麼會發生這種情況? 我使用的Eclipse 3.5.2,GAE/J 1.4.2和Ubuntu 10.10
谷歌搜索爲例外,我發現這裏只有一個討論: http://groups.google.com/group/google-appengine-java/browse_thread/thread/19f250b1ff0e4342
但改變var channel = new goog.appengine.Channel(token);
到var channel = new goog.appengine.Channel(uid);
沒有解決任何問題(並且,從我的理解,它不應該)
對不起,我應該補充說我正在本地主機上運行它,並且沒有調用socket.onError。 – Aleadam 2011-03-20 05:27:08