如何实现连接/断开(GAE Channel API,Java)?

发布于 2024-12-27 10:34:58 字数 937 浏览 1 评论 0原文

这是我的 app.yaml 的相关部分:

handlers:
[...]
- url: /_ah/channel/connected
  servlet: com.[MYAPP].server.channel.ChannelConnected
  name: ChannelConnected
- url: /_ah/channel/disconnected
  servlet: com.[MYAPP].server.channel.ChannelDisconnected
  name: ChannelDisconnected
- url: /*
  filter: com.google.inject.servlet.GuiceFilter
  login: required

[...]

inbound_services:
  - channel_presence

但 App Engine 似乎都无法识别 ChannelDisconnected 和 ChannelConnected 。开发服务器 (SDK 1.6.1) 的输出:

Jan 18, 2012 1:08:37 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
Warnung: No file found for: /_ah/channel/connected/

以及网络日志:

0.1.0.10 - - [18/Jan/2012:05:01:37 -0800] "POST /_ah/channel/connected/ HTTP/1.1" 404 346 - - "[MYID].appspot.com" ms=42 cpu_ms=88 api_cpu_ms=65 cpm_usd=0.002547 instance=00c61b117ce7311fe771ffe792d63bf0a07784

This is the relevant part of my app.yaml:

handlers:
[...]
- url: /_ah/channel/connected
  servlet: com.[MYAPP].server.channel.ChannelConnected
  name: ChannelConnected
- url: /_ah/channel/disconnected
  servlet: com.[MYAPP].server.channel.ChannelDisconnected
  name: ChannelDisconnected
- url: /*
  filter: com.google.inject.servlet.GuiceFilter
  login: required

[...]

inbound_services:
  - channel_presence

But neither ChannelDisconnected nor ChannelConnected seem to be recognized by App Engine. Output from the Dev Server (SDK 1.6.1):

Jan 18, 2012 1:08:37 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
Warnung: No file found for: /_ah/channel/connected/

And the web log:

0.1.0.10 - - [18/Jan/2012:05:01:37 -0800] "POST /_ah/channel/connected/ HTTP/1.1" 404 346 - - "[MYID].appspot.com" ms=42 cpu_ms=88 api_cpu_ms=65 cpm_usd=0.002547 instance=00c61b117ce7311fe771ffe792d63bf0a07784

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

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

发布评论

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

评论(2

殊姿 2025-01-03 10:34:58

在连接和断开连接的处理程序末尾添加反斜杠:

- url: /_ah/channel/connected/
  servlet: com.[MYAPP].server.channel.ChannelConnected
  name: ChannelConnected
- url: /_ah/channel/disconnected/
  servlet: com.[MYAPP].server.channel.ChannelDisconnected
  name: ChannelDisconnected

Add a backslash to the end of your connected and disconnected handlers:

- url: /_ah/channel/connected/
  servlet: com.[MYAPP].server.channel.ChannelConnected
  name: ChannelConnected
- url: /_ah/channel/disconnected/
  servlet: com.[MYAPP].server.channel.ChannelDisconnected
  name: ChannelDisconnected
ゞ花落谁相伴 2025-01-03 10:34:58

在您的 yaml 片段中,您的入站服务被注释掉。如果您的实际部署出现这种情况,则可能是导致问题的原因。

In your yaml snippet your inbound services are commented out. If this is the case on your actual deployment that might be the cause of your issues.

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