google appengine 通道 API (Java) 问题

发布于 2024-11-07 12:35:00 字数 7060 浏览 1 评论 0原文

我在使用 Channel API 时遇到问题 - 任何帮助将不胜感激。

我对本地开发服务器上的 API 没有任何问题,但是当我将其放在 appspot 上时,我抛出了一个深奥的异常。附加了完整的堆栈跟踪,但标题是:

com.google.appengine.api.channel.ChannelFailureException: An unexpected error occurred.     
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 2: Unknown

我已将应用程序简化为 servlet 和 jsp(均附加),以确保我没有做任何过于复杂的事情。阅读这个论坛和其他论坛上的一些消息,这可能是我滥用令牌与频道密钥,但我已经尝试了我能想到的所有组合,但都无济于事!

servlet 的片段:

ChannelService channelService = ChannelServiceFactory.getChannelService();
String channelKey = getChannelKey(userService.getCurrentUser().getUserId());
String token = channelService.createChannel(channelKey);

ChannelService channelService = ChannelServiceFactory.getChannelService();
channelService.sendMessage(new ChannelMessage(channelKey, message)); 

jsp 的片段:

channel = new goog.appengine.Channel(channelToken);
socket = channel.open();

从堆栈跟踪来看,客户端连接到通道正常,并成功向上发送消息,但 servlet 将消息写回通道是失败的部分。

预先非常感谢您的帮助!

代码:

ChannelTestController.java < /一>

<一href="https://bitbucket.org/pinkius/chessweb/src/d797865ba18e/src/main/webapp/WEB-INF/jsp/ChannelTestPage.jsp" rel="nofollow">ChannelTestPage.jsp

日志:

/ChannelTestMessage.do com.google.appengine.api.channel.ChannelFailureException:发生意外错误。 在 com.google.appengine.api.channel.ChannelServiceImpl.getExceptionForError(ChannelServiceImpl.java:112) 在 com.google.appengine.api.channel.ChannelServiceImpl.sendMessage(ChannelServiceImpl.java:68) 在 com.webstersmalley.chessweb.web.ChannelTestController.sendMessage(ChannelTestController.java:74) 在 com.webstersmalley.chessweb.web.ChannelTestController.getChannelTestMessage(ChannelTestController.java:68) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:43) 在 org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 在org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) 在org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) 在 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) 在 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) 在 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) 在 org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 在 org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 在 org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) 在 org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 在 org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) 在 org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) 在 org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) 在 org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 在 org.mortbay.jetty.Server.handle(Server.java:326) 在 org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) 在 org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923) 在 org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 在 com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:439) 在 com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:573) 在 com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448) 在com.google.tracing.TraceContext.runInContext(TraceContext.java:688) 在 com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326) 在 com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318) 在 com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 在 java.lang.Thread.run(Thread.java:636) 引起原因:com.google.apphosting.api.ApiProxy$ApplicationException:ApplicationError:2:未知 在 com.google.net.rpc.RpcStub$RpcCallbackDispatcher$1.runInContext(RpcStub.java:1050) 在 com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448) 在com.google.tracing.TraceContext.runInContext(TraceContext.java:688) 在 com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326) 在 com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318) 在 com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446) 在 com.google.net.rpc.RpcStub$RpcCallbackDispatcher.rpcFinished(RpcStub.java:1071) 在 com.google.net.rpc.RPC.internalFinish(RPC.java:2184) 在 com.google.net.rpc.impl.RpcNetChannel.finishRpc(RpcNetChannel.java:2338) 在 com.google.net.rpc.impl.RpcNetChannel.messageReceived(RpcNetChannel.java:1267) 在 com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:328) 在 com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:299) 在 com.google.net.async.Connection.handleReadEvent(Connection.java:474) 在 com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:831) 在 com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:207) 在 com.google.net.async.EventDispatcher.loop(EventDispatcher.java:103) 在 com.google.net.async.GlobalEventRegistry$2.runLoop(GlobalEventRegistry.java:95) 在 com.google.net.async.LoopingEventDispatcher$EventDispatcherThread.run(LoopingEventDispatcher.java:385)

I'm having problems with the Channel API - any help would be greatly appreciated.

I've no problems with the API on the local dev server, but when I put it up on appspot, I get an esoteric exception thrown. Full stack trace is attached, but the headline is:

com.google.appengine.api.channel.ChannelFailureException: An unexpected error occurred.     
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 2: Unknown

I've boiled the app down to a servlet and a jsp (both attached) to make sure I'm not doing anything over-complicated. Reading some of the messages on this forum and others it might be my misuse of tokens vs channel keys, but I've tried every combination I can think of to no avail!

Snippet of servlet:

ChannelService channelService = ChannelServiceFactory.getChannelService();
String channelKey = getChannelKey(userService.getCurrentUser().getUserId());
String token = channelService.createChannel(channelKey);

and

ChannelService channelService = ChannelServiceFactory.getChannelService();
channelService.sendMessage(new ChannelMessage(channelKey, message)); 

Snippet of jsp:

channel = new goog.appengine.Channel(channelToken);
socket = channel.open();

From the stack trace, the client is connecting to the channel OK, and successfully sends a message up, but the servlet writing the message back to the channel is the bit that fails.

Thanks very much in advance for any help!

Code:

ChannelTestController.java

ChannelTestPage.jsp

Logs:

/ChannelTestMessage.do
com.google.appengine.api.channel.ChannelFailureException: An unexpected error occurred.
at com.google.appengine.api.channel.ChannelServiceImpl.getExceptionForError(ChannelServiceImpl.java:112)
at com.google.appengine.api.channel.ChannelServiceImpl.sendMessage(ChannelServiceImpl.java:68)
at com.webstersmalley.chessweb.web.ChannelTestController.sendMessage(ChannelTestController.java:74)
at com.webstersmalley.chessweb.web.ChannelTestController.getChannelTestMessage(ChannelTestController.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:43)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:439)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:573)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 2: Unknown
at com.google.net.rpc.RpcStub$RpcCallbackDispatcher$1.runInContext(RpcStub.java:1050)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at com.google.net.rpc.RpcStub$RpcCallbackDispatcher.rpcFinished(RpcStub.java:1071)
at com.google.net.rpc.RPC.internalFinish(RPC.java:2184)
at com.google.net.rpc.impl.RpcNetChannel.finishRpc(RpcNetChannel.java:2338)
at com.google.net.rpc.impl.RpcNetChannel.messageReceived(RpcNetChannel.java:1267)
at com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:328)
at com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:299)
at com.google.net.async.Connection.handleReadEvent(Connection.java:474)
at com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:831)
at com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:207)
at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:103)
at com.google.net.async.GlobalEventRegistry$2.runLoop(GlobalEventRegistry.java:95)
at com.google.net.async.LoopingEventDispatcher$EventDispatcherThread.run(LoopingEventDispatcher.java:385)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

み零 2024-11-14 12:35:00

我在 Google 自己的 Appengine Java API 论坛上交叉发布了这个问题,并在那里得到了解答。

总结是,当打开高复制(现在所有新应用程序默认情况下都是如此)并且使用非默认版本时,就会出现问题。

我的应用程序是最近的一个(因此高代表处于开启状态),并且我正在尝试一系列不同的方法来让通道正常工作,所以我没有使用我的应用程序的默认版本。将默认值切换为指向最新版本并使用该 URL 导致问题消失!

I cross-posted this on Google's own discussion forum for the Appengine Java API, and it was answered there.

A summary is that the problem occurs when high replication is switched on (as all new apps are, by default, now), and the non-default version is being used.

My app was a recent one (hence high rep was on), and I was trying a bunch of different ways of getting the Channels to work, so I was not using the default version of my app. Switching default to point at the latest version and using that URL caused the problem to go away!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文