在 Android 上使用 Cometd/Bayeux 的系统要求

发布于 2024-08-29 13:43:37 字数 779 浏览 10 评论 0原文

我正在尝试使用 iJetty 在 Android 上实现 Cometd/Bayeux 服务器。 Jetty 实现本身可以很好地为静态页面和 servlet 提供服务。我正在尝试加大赌注并在手机上创建一个 Bayeux 应用程序,但遇到了一些麻烦。我可以访问包含 dojo cometd 脚本的页面,但无法订阅该频道。当我查看 firebug/chome 开发人员工具时,我看到一系列持续几毫秒的帖子/获取(~14)。但是,当我在普通计算机上运行 cometd 应用程序时,在超时并重新打开连接之前,posts/gets 会持续几秒钟(约 14 秒)。根据我对 HTTP 连续性如何工作的理解,第二种情况对我来说很有意义。所以我认为有些东西不允许这些连接保持打开状态并过早返回值并因此关闭连接。我会发布我的源代码,但我不知道该发布什么,除了发布所有内容......(虽然它是开源的,所以如果你想看看它在 http://webtext-android.googlecode.com)。

所以我的问题是,是否有人认为 Android 系统可能存在一些潜在的限制,导致这些 servlet 无法工作? Jetty Bayeux 实现是否对底层系统做出了假设?或者更有可能的是我对 ContinuationCometdServelt 的实现很糟糕?我应该注意到,来自客户端的所有 post/gets 都会返回 200 OK 消息,因此我不倾向于认为 Android 系统只是终止连接。

我知道这有点离谱,我肯定会尝试做一些不寻常的事情,但任何建议或提示将不胜感激。

I'm trying to implement a Cometd/Bayeux server on Android using iJetty. The Jetty implementation itself works just fine serving static pages along with servlets. I am trying to up the ante a bit and create a Bayeux application on the phone but I'm having some trouble. I can hit the page that has the dojo cometd scripts on it, but I am unable to subscribe to the channel. When I view firebug/chome developer tools, I see a series of posts/gets that last a couple of milliseconds (~14). However, when I run a cometd application on a normal machine, the posts/gets last several seconds (~14 seconds) before timing out and reopening the connection. This second scenario makes sense to me with my understanding of how continuation in HTTP works. So I'm thinking that something is not allowing those connections to hang open and prematurely returning a value and consequently closing the connection. I would post my source but I'm not sure what to post short of posting everything...(it is open source though so if you want to have a look it's at http://webtext-android.googlecode.com).

So my question is, does anybody think that there could be some underlying limitation imposed by the Android system that is preventing these servlets from working? Are there assumptions that are made by the Jetty Bayeux implementation with regards to the underlying system? Or is it more likely that somehow I have a bad implementation of the ContinuationCometdServelt? I should note that all of the posts/gets from the client return 200 OK messages so I'm not inclined to think that the Android system is simply terminating the connection.

I know this is a bit off the wall and I'm definitely trying to do something a bit out of the ordinary but any suggestions or tips would be greatly appreciated.

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

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

发布评论

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

评论(1

凉栀 2024-09-05 13:43:37

如果有人发现这一点并遇到类似的问题(这适用于所有 cometd 实现,无论主机如何),我发现问题在于使用 Google js 库。由于某种原因,我从 Google (1.4) 加载的 dojo 脚本没有 cometd 的有效实现。我将 dojo 脚本切换为 jetty-1.6.23 示例所使用的脚本,并且它运行良好。

In case anybody discovers this and has similar problems (this applies to all cometd implementations regardless of host), I discovered that the issue was with using the Google js library. For some reason, the dojo scripts I was loading from Google (1.4) didn't have a valid implementation of cometd. I switched my dojo script to the one that was used by the jetty-1.6.23 example and it works perfectly.

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