使用 Strope 连接到 BOSH 会话时遇到问题
我正在客户端使用 XMPP over BOSH 和 Strope 实现实时通知系统,但遇到了一些问题。当我登录我的网站时,我在后端建立 BOSH 连接并将 JID、SID 和 RID 保存为 cookie。当页面重新加载时,我从 cookie 中获取数据并使用 Strope 的附加功能附加到该会话。我收到回拨状态,表明我已被连接。
我面临的第一个问题是每隔一秒左右就会发送一次请求。 这些是请求标头:
请求网址:http://localhost:7070/http-bind/
请求方式:POST
状态代码:200 OK请求标头
接受:*/*
接受字符集:UTF-8,*;q=0.5
接受编码:gzip、deflate、sdch
接受语言:sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4
缓存控制:max-age=0
连接:保持活动
内容长度:77
Cookie:JSESSIONID=ibxwvm3ophp8; jiveforums.admin.logviewer="debug.size=0&info.size=0&warn.size=0&error.size=0"
主机:本地主机:7070
来源:http://***
参考来源:http://***/flXHR/flXHR.swf
用户代理:Mozilla/5.0(Macintosh;Intel Mac OS X 10_6_7)AppleWebKit/535.1(KHTML,如 Gecko)Chrome/13.0.782.107 Safari/535.1 内容类型:application/x-www-form-urlencoded表单数据
<正文摆脱:'3007' xmlns响应标头
内容长度:57
内容类型:text/xml;字符集=UTF-8
服务器:Jetty(7.0.2-SNAPSHOT)
我看不到任何响应内容,所以我不确定是什么原因造成的。发送的表单数据看起来像无效且不完整的 XML,这是导致它的原因还是 Chrome 在调试器中格式化它的方式?
我面临的另一个问题是当我重新加载页面时。我已将卸载事件绑定到窗口对象,其中我将 RID 加一并将其保存到 cookie。但是,当页面重新加载时,它表示我已附加到 BOSH 会话,但随后收到以下错误消息:
POST http://localhost:7070/http-bind/ 404(不是找到)(本地主机)
未捕获错误:16,ioError,发生阻止请求完成的错误。 (flensed.js)
下一个请求将抛出 404(无效的 SID)而不是 404(未找到),并且每 70 秒以上重复一次。
还有其他人遇到过这个问题并且知道如何解决吗?我很沮丧!
预先感谢,
皮埃尔
I'm implementing a real-time notification system using XMPP over BOSH and Strophe on the client-side, but I'm having some problems. When I log onto my website I establish a BOSH connection in back-end and save JID, SID and RID as cookies. When the page is reloaded I get the data from the cookies and attach to that session using Strophe's attach function. I get a callback status which says I've been attached.
The first problem I'm facing is that requests are being sent every second second or so.
These are the request headers:
Request URL:http://localhost:7070/http-bind/
Request Method:POST
Status Code:200 OKRequest Headers
Accept: */*
Accept-Charset:UTF-8,*;q=0.5
Accept-Encoding:gzip,deflate,sdch
Accept-Language:sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:77
Cookie:JSESSIONID=ibxwvm3ophp8; jiveforums.admin.logviewer="debug.size=0&info.size=0&warn.size=0&error.size=0"
Host:localhost:7070
Origin:http://***
Referer:http://***/flXHR/flXHR.swf
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1
content-type:application/x-www-form-urlencodedForm Data
< body rid:'3007' xmlnsResponse Headers
Content-Length:57
Content-Type:text/xml;charset=UTF-8
Server:Jetty(7.0.2-SNAPSHOT)
I can't see any response content so I'm not sure what's causing it. The form data being sent looks like invalid and incomplete XML, is this what causes it or is that just how Chrome would format it in the debugger?
The other problem I'm facing is when I reload the page. I've bound an unload event to the window object in which I increase the RID by one and save it to the cookie. However, when the page is reloaded it says that I've attached to the BOSH session but then I get the following error message:
POST http://localhost:7070/http-bind/ 404 (Not Found) (localhost)
Uncaught Error: 16, ioError, An error occured preventing completion of the request. (flensed.js)
The next request will throw 404 (Invalid SID.) instead of 404 (Not Found) and repeats every 70+ seconds or so.
Has anyone else gotten this problem and know how to solve it? I'm frustrated!
Thanks in advance,
Pierre
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管您已经放弃了实现,但您提到的第一个问题仍然是客户端服务器在 Openfire 连接中执行的连续 ping 操作,以便服务器知道客户端已启动并正在运行。第二个错误并不完全确定,但很可能是在您中断之间的通信并且没有优雅地终止它时出现的。这可能会导致 strope 客户端在再次绑定端口时遇到一些问题。由于上述 ping 机制,您还会反复遇到该问题。您可以尝试在触发 window.onbeforeunload 事件后调用 connection.disconnect 方法。这将确保优雅终止并因此正确重新连接。
Although you have abandoned the implementation, still the first problem you have mentioned is simply a continuous ping which the client server do in Openfire connections in order for the server to know that the client is up and running. The second error, not exactly sure but probably, arises as you are interrupting the communication in between and not terminating it gracefully. This may cause the strophe client to face some problems in binding to the port again. Also you face the problem repeatedly due to the ping mechanism mentioned above. You could've tried calling the connection.disconnect method after the window.onbeforeunload event was triggered. This would have ensured graceful termination and hence proper reconnection.