服务器端口配置丢失



我试图让Autobahn示例在Python 3.3和asyncio 0.4.1的虚拟环境下工作,但Chrome一直显示1006.

在发现调试选项(factory.debug = True)之后,我遇到了以下服务器输出:
[('debug', True, 'WebSocketServerFactory'),
 ('debugCodePaths', False, 'WebSocketServerFactory'),
 ('logOctets', False, 'WebSocketServerFactory'),
 ('logFrames', False, 'WebSocketServerFactory'),
 ('trackTimings', False, 'WebSocketServerFactory'),
 ('allowHixie76', False, 'WebSocketServerFactory'),
 ('utf8validateIncoming', True, 'WebSocketServerFactory'),
 ('applyMask', True, 'WebSocketServerFactory'),
 ('maxFramePayloadSize', 0, 'WebSocketServerFactory'),
 ('maxMessagePayloadSize', 0, 'WebSocketServerFactory'),
 ('autoFragmentSize', 0, 'WebSocketServerFactory'),
 ('failByDrop', True, 'WebSocketServerFactory'),
 ('echoCloseCodeReason', False, 'WebSocketServerFactory'),
 ('openHandshakeTimeout', 5, 'WebSocketServerFactory'),
 ('closeHandshakeTimeout', 1, 'WebSocketServerFactory'),
 ('tcpNoDelay', True, 'WebSocketServerFactory'),
 ('versions', [0, 8, 13], 'WebSocketServerFactory'),
 ('webStatus', True, 'WebSocketServerFactory'),
 ('requireMaskedClientFrames', True, 'WebSocketServerFactory'),
 ('maskServerFrames', False, 'WebSocketServerFactory'),
 ('perMessageCompressionAccept',
  <function WebSocketServerFactory.resetProtocolOptions.<locals>.<lambda> at 0x7faa2f6ac830>,
  'WebSocketServerFactory')]
connection accepted from peer 127.0.0.1:48000
received HTTP request:
b'GET / HTTP/1.1rnUpgrade: websocketrnConnection: UpgradernHost: 127.0.0.1:9000rnOrigin: http://127.0.0.1:8000rnPragma: no-cachernCache-Control: no-cachernSec-WebSocket-Key: oOzANrxgacD4wL0/x6EUEA==rnSec-WebSocket-Version: 13rnSec-WebSocket-Extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-framernUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36rnCookie: csrftoken=jznso3LOJR5EGYAmNSbuW3q8q2SurO71rnrn'

received HTTP status line in opening handshake : GET / HTTP/1.1
received HTTP headers in opening handshake : {'sec-websocket-extensions': 'permessage-deflate; client_max_window_bits, x-webkit-deflate-frame', 'cookie': 'csrftoken=jznso3LOJR5EGYAmNSbuW3q8q2SurO71', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36', 'pragma': 'no-cache', 'upgrade': 'websocket', 'host': '127.0.0.1:9000', 'cache-control': 'no-cache', 'sec-websocket-key': 'oOzANrxgacD4wL0/x6EUEA==', 'sec-websocket-version': '13', 'connection': 'Upgrade', 'origin': 'http://127.0.0.1:8000'}
failing WebSocket opening handshake ('port 9000 in HTTP Host header '127.0.0.1:9000' does not match server listening port None')
connection from 127.0.0.1:48000 lost

如果在示例中显式设置为9000,端口如何为None ?

我们最近合并了一个补丁,允许在不提供WebSocket URL的情况下定义工厂,调整了示例,但没有发布到PyPi。对不起。

我刚刚发布了一个版本(0.8.6)。所以你可以:

pip install -U autobahn

或者将示例代码更改为

factory = WebSocketServerFactory("ws://localhost:9000")

相关内容

  • 没有找到相关文章

最新更新