3

我在这里看到了类似失败的报告:https ://groups.google.com/forum/?fromgroups=#!topic/sockjs/QNtA1_p_arU ,但我的问题似乎有所不同。

我的设置:客户端连接到https://www.mysite.com/sockjsSockJS,实际页面在https://www.mysite.com/blah/blah/blah. 页面上的所有外部元素(例如 css 和 js)都使用https提供,包括 SockJS-Client(https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.js,最新版本应该是 0.3.4)。后端是用 SockJS-Tornado 制作的。

问题 1:我指定使用以下协议:

var options = {protocols_whitelist: ["websocket", "xhr-streaming", "xdr-streaming", "xhr-polling", "xdr-polling", "iframe-htmlfile", "iframe-eventsource", "iframe-xhr-polling"], debug: true};             
conn = new SockJS("https://www.mysite.com/sockjs", options);

但是,似乎 IE9 只是使用了最差协议iframe-htmlfile,正如我在服务器日志中看到的那样:

INFO:root:200 GET /sockjs/info?t=1353062888578 (127.0.0.1) 0.51ms
INFO:root:200 GET /sockjs/iframe.html (127.0.0.1) 22.21ms

为什么不使用xdr-streamingor xdr-polling?在 SockJS 文档中,它在 'IE8, 9 (cookies=no)' 下标记了这两个协议,这是否意味着 SockJS 只会在浏览器禁用 cookie 时使用它们?

问题 2:使用协议iframe-htmlfile时,用户会在页面上收到'Only Secure Content is Displayed'警告,表明存在混合内容问题。但是,没有其他经过测试的浏览器报告此警告(例如 Chrome、FireFox、Safari),并且如前所述,页面上的每个外部资源都是通过 https 提供的。为什么是这样?它与使用的这个特定协议有关iframe-htmlfile吗?

同时,SockJS 很难连接到服务器并发送消息。这是我在服务器日志中看到的:

INFO:root:200 GET /sockjs/info?t=1353062888578 (127.0.0.1) 0.51ms
INFO:root:200 GET /sockjs/iframe.html (127.0.0.1) 22.21ms
INFO:root:200 GET /sockjs/info?t=1353062922712 (127.0.0.1) 0.39ms
connection openned for: 127.0.0.1
INFO:root:200 GET /sockjs/info?t=1353062963868 (127.0.0.1) 0.36ms
WARNING:root:Read error on 12: [Errno 104] Connection reset by peer
WARNING:root:error on read
Traceback (most recent call last):
  File "/home/ml/envs/.virtualenvs/sockapp/local/lib/python2.7/site-packages/tornado/iostream.py", line 355, in _handle_read
    if self._read_to_buffer() == 0:
  File "/home/ml/envs/.virtualenvs/sockapp/local/lib/python2.7/site-packages/tornado/iostream.py", line 422, in _read_to_buffer
    chunk = self._read_from_socket()
  File "/home/ml/envs/.virtualenvs/sockapp/local/lib/python2.7/site-packages/tornado/iostream.py", line 403, in _read_from_socket
    chunk = self.socket.recv(self.read_chunk_size)
error: [Errno 104] Connection reset by peer
subject disconnection from: None
Message handled in: 0 ms
INFO:root:200 GET /sockjs/369/rpf1d1vl/htmlfile?c=_jp.aepnvri (127.0.0.1) 60006.30ms

最后一个错误似乎是超时。当我关闭 IE9 中的警告对话框时,连接似乎打开了,但之后没有从浏览器接收到消息(浏览器应在连接打开后立即发送消息)。我想知道这是否与之前的混合内容警告有关。

4

1 回答 1

5

我认为我们能够在 SockJS 邮件列表中发现您的问题。快速回顾:

问题 1 - 您的服务器要求客户端仅使用执行 cookie 的传输(出于负载平衡原因),这意味着无法使用基于 XDR 的传输(XDR 无法执行 cookie)。

问题 2 - 您忘记sockjs_url在服务器端设置参数,包括来自 https(而不是 http)的 sockjs javascript。这就是您收到混合内容警告的原因。

于 2012-11-22T14:11:15.787 回答