Javascript 发送消息时未调用WebSocket onmessage()

Javascript 发送消息时未调用WebSocket onmessage(),javascript,python,google-chrome-extension,Javascript,Python,Google Chrome Extension,我用的是高速公路0.4.10(https://github.com/oberstet/Autobahn)作为WebSocket服务器向Google Chrome扩展发送消息。我可以使用WebSocket()打开和关闭连接,但是当我调用autobahn.WebSocket.WebSocketServerProtocol.sendMessage()时,消息似乎已发送,但在连接关闭之前不会发送 WebSocketServerProtocol的sendMessage()(源自WebSocketProto

我用的是高速公路0.4.10(https://github.com/oberstet/Autobahn)作为WebSocket服务器向Google Chrome扩展发送消息。我可以使用
WebSocket()
打开和关闭连接,但是当我调用
autobahn.WebSocket.WebSocketServerProtocol.sendMessage()
时,消息似乎已发送,但在连接关闭之前不会发送

WebSocketServerProtocol的
sendMessage()
(源自WebSocketProtocol)的api可在以下位置找到:

以前有人遇到过这个问题吗

我在客户端的代码是(js):

在服务器上(python)


Autobahn和我的Chrome版本(17.0.963.46)都出现在使用WebSocket草案协议第13版时(根据我从标题和文档中得到的信息)。

发现这是一个线程问题,一些线程阻塞了twisted reactor

见:

Autobahn采用铬合金(经过测试达到v19..金丝雀)

你能试试这个吗

演示以查看是否存在一般问题

如果运行,请将您的扩展指向该演示服务器。。它每秒会给你发送1个滴答声

您还可以通过将factory行更改为以下代码来启用调试输出

2更多说明:

  • 您不需要sync=True选项(它实际上是一个高级选项..主要用于Autobahn WS-testsuite)

  • 你可能想加入。。更快地得到答案。。我在这里偶然发现了你的Q


披露:我是Autobahn的作者,为Tavendo工作。

感谢您的回复,事实上我刚刚发现了这个问题(上面的答案)。我将取消sync=True选项-不确定从何处获得它。
ws = new WebSocket('ws://localhost:4444');
ws.onmessage = function(event) {
  console.log('hii');
}
#json is a string object
def sendEvent(self, json):
    print 'to', self.peerstr
    self.sendMessage(json, sync=True)