我正在研究一個python3.3客戶端:我需要連接到一個棘手的php服務器並訂閱一個主題。我已經安裝了asyncio和autobahn。websocket + wamp:服務器php和客戶端python,tcp連接丟失
我按照這個例子https://github.com/tavendo/AutobahnPython/blob/master/examples/asyncio/wamp/beginner/client.py但它不起作用,握手後的tcp連接下降。
激活所有調試結果是:
[('debug', True, 'WampWebSocketClientFactory'),
('debugCodePaths', False, 'WampWebSocketClientFactory'),
('logOctets', True, 'WampWebSocketClientFactory'),
('logFrames', True, 'WampWebSocketClientFactory'),
('trackTimings', False, 'WampWebSocketClientFactory'),
('allowHixie76', False, 'WampWebSocketClientFactory'),
('utf8validateIncoming', True, 'WampWebSocketClientFactory'),
('applyMask', True, 'WampWebSocketClientFactory'),
('maxFramePayloadSize', 0, 'WampWebSocketClientFactory'),
('maxMessagePayloadSize', 0, 'WampWebSocketClientFactory'),
('autoFragmentSize', 0, 'WampWebSocketClientFactory'),
('failByDrop', True, 'WampWebSocketClientFactory'),
('echoCloseCodeReason', False, 'WampWebSocketClientFactory'),
('openHandshakeTimeout', 5, 'WampWebSocketClientFactory'),
('closeHandshakeTimeout', 1, 'WampWebSocketClientFactory'),
('tcpNoDelay', True, 'WampWebSocketClientFactory'),
('autoPingInterval', 0, 'WampWebSocketClientFactory'),
('autoPingTimeout', 0, 'WampWebSocketClientFactory'),
('autoPingSize', 4, 'WampWebSocketClientFactory'),
('version', 18, 'WampWebSocketClientFactory'),
('acceptMaskedServerFrames', False, 'WampWebSocketClientFactory'),
('maskClientFrames', True, 'WampWebSocketClientFactory'),
('serverConnectionDropTimeout', 1, 'WampWebSocketClientFactory'),
('perMessageCompressionOffers', [], 'WampWebSocketClientFactory'),
('perMessageCompressionAccept',
<function WebSocketClientFactory.resetProtocolOptions.<locals>.<lambda> at 0x00000000031619D8>,
'WampWebSocketClientFactory')]
connection to 192.168.100.218:44444 established
TX Octets to 192.168.100.218:44444 : sync = False, octets = b'474554202f20485454502f312e310d0a557365722d4167656e743a204175746f6261686e507974686f6e2f302e392e310d0a486f73743a206c6f63616c686f73743a38300d0a557067726164653a20576562536f636b65740d0a436f6e6e656374696f6e3a20557067726164650d0a507261676d613a206e6f2d63616368650d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a5365632d576562536f636b65742d4b65793a204f4d753955674b565442697375665741796246332b413d3d0d0a5365632d576562536f636b65742d50726f746f636f6c3a2077616d702e322e6a736f6e2e626174636865642c77616d702e322e6a736f6e0d0a5365632d576562536f636b65742d56657273696f6e3a2031330d0a0d0a'
GET/HTTP/1.1
User-Agent: AutobahnPython/0.9.1
Host: localhost:80
Upgrade: WebSocket
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: OMu9UgKVTBisufWAybF3+A==
Sec-WebSocket-Protocol: wamp.2.json.batched,wamp.2.json
Sec-WebSocket-Version: 13
RX Octets from 192.168.100.218:44444 : octets = b'485454502f312e312031303120537769746368696e672050726f746f636f6c730d0a557067726164653a20776562736f636b65740d0a436f6e6e656374696f6e3a20557067726164650d0a5365632d576562536f636b65742d4163636570743a2049332f372f7745784b626d65705975796835444177384d683936593d0d0a582d506f77657265642d42793a20526174636865742f302e322e370d0a0d0a81265b302c2235343235363164383232613866222c312c22526174636865745c2f302e322e37225d'
received HTTP response:
b'HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: I3/7/wExKbmepYuyh5DAw8Mh96Y=\r\nX-Powered-By: Ratchet/0.2.7\r\n\r\n'
received HTTP status line in opening handshake : HTTP/1.1 101 Switching Protocols
received HTTP headers in opening handshake : {'connection': 'Upgrade', 'upgrade': 'websocket', 'sec-websocket-accept': 'I3/7/wExKbmepYuyh5DAw8Mh96Y=', 'x-powered-by': 'Ratchet/0.2.7'}
WAMP-over-WebSocket transport lost: wasClean = False, code = 1006, reason = 'connection was closed uncleanly (I failed the WebSocket connection by dropping the TCP connection)'
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\autobahn-0.9.1-py3.3.egg\autobahn\wamp\websocket.py", line 75, in onClose
self._session.onClose(wasClean)
AttributeError: 'WampWebSocketClientProtocol' object has no attribute '_session'
connection to 192.168.100.218:44444 lost
服務器確定(它與它連接的其他應用程序)。任何建議? Thx!
謝謝,你擊中了目標,但我以不同的方式解決了 – fryederich 2014-10-09 07:45:37