Closed fryederich closed 10 years ago
Yup. Any WebSocket server and client that speak the standard RFC6455 protocol can work together.
Thank you cboden (also for adding label). Some details: python 3.3 with asyncio and autobahn 0.9.1, Because server uses WampServiceInterface, I've written a wamp client script following this example https://github.com/tavendo/AutobahnPython/blob/master/examples/asyncio/wamp/beginner/client.py The connection to server is established but it drops after the handshake. The output is:
[('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.
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
It looks like the version of Autobahn you're using only speaks version 2 of the WAMP protocol.
Sec-WebSocket-Protocol: wamp.2.json.batched,wamp.2.json
Ratchet speaks version 1. Can you try using a version of Autobahn with the 0.8.x tag?
Yes, it works!!!! thank!
But I need python 3.3: wamp v1 can be used with Twisted only, and Twisted is only for python 2.7. In your opinion, opening a python33 websocket connection and re-implementing the wamp1 specification is hard (basically I have to subscribe to a topic and receive events)? Any other suggestion?
I'm a beginner, there is a php-ratchet server using WampServiceInterface and I'd like to make a python client that subscribes to a topic on this server. It is possible?