Pregunta

I'm trying to get the Autobahn example to work under a virtual env with Python 3.3 and asyncio 0.4.1, but Chrome keeps displaying a 1006.

After discovering the debug option (factory.debug = True), I encountered the following server output:

[('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.1\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nHost: 127.0.0.1:9000\r\nOrigin: http://127.0.0.1:8000\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nSec-WebSocket-Key: oOzANrxgacD4wL0/x6EUEA==\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36\r\nCookie: csrftoken=jznso3LOJR5EGYAmNSbuW3q8q2SurO71\r\n\r\n'


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

How can the port be None if it's explicitly set to 9000 in the example?

¿Fue útil?

Solución

Uups. We recently merged a patch that allows factories to be defined without providing a WebSocket URL, adjusted the examples, but did no release to PyPi. Sorry.

I just did a release (0.8.6) now. So you can either:

pip install -U autobahn

OR change the example code to

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

Sorry again ..

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top