我有一个使用autobahn WebSocket框架使用twisted实现的WebSocket服务器。当程序使用python运行时,WebSocket服务器运行正常。但是,如果我通过创建tac文件作为扭曲服务使用twistd服务器运行程序运行它,我在服务器中得到以下错误,而任何客户端尝试建立连接并且握手失败。
2015-12-08 07:17:56,022 - CRITICAL - twisted.publishToNewObserver() 154 Unhandled Error
Traceback (most recent call last):
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/python/log.py", line 84, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
why = selectable.doRead()
--- <exception caught here> ---
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 1067, in doRead
protocol = self.factory.buildProtocol(self._buildAddr(addr))
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/internet/protocol.py", line 135, in buildProtocol
p = self.protocol()
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 665, in __init__
self.is_closed = txaio.create_future()
File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/txaio/_unframework.py", line 43, in _throw_usage_error
"To use txaio, you must first select a framework "
exceptions.RuntimeError: To use txaio, you must first select a framework with .use_twisted() or .use_txaio()
答案 0 :(得分:2)
我今天发现了同样的问题。 您应该将txaio降级到版本1.1.0
这是我的点子名单 高速公路(0.10.9) autobahntestsuite(0.7.3) 扭曲(15.4.0) txaio(1.1.0) zope.interface(4.1.3)
答案 1 :(得分:0)
我的Ubuntu系统中没有发生此问题。我在使用Machine Image Amazon Linux AMI的ec2实例中遇到了这个问题。似乎txaio无法检测到可用的扭曲框架。除了上面提到的@ helder.vasc之外的另一个修复是将框架指定为显式扭曲。 在tac文件中添加以下内容解决了这个问题:
import txaio
txaio.use_twisted()
请注意天气,这是解决此问题的完美方法。
答案 2 :(得分:0)
你可以尝试使用高速公路大师吗?这应该在那里修复,但是还没有包含修复的版本(dd1cff8f9480a125e510108482bfaf5b9eedc916)。
您可以像这样安装master:pip install https://github.com/crossbario/autobahn-python/archive/master.zip
答案 3 :(得分:0)
AutobahnTestSuite刚刚更新并纠正了这个问题:
高速公路(0.10.9) autobahntestsuite(0.7.4) 扭曲(15.5.0) txaio(2.1.0)