It seems to be really hard to find anything about the WAMP.2 protocol. I am trying to connect to a webSocket that uses WAMP.2, using Python, autobahn and twisted. However, I keep getting this error:
2018-03-09 14:54:53+0100 [-] Log opened.
2018-03-09 14:54:53+0100 [-] Starting factory
<autobahn.twisted.websocket.WebSocketClientFactory object at 0x000002A461F489B0>
2018-03-09 14:54:53+0100 [-] failing WebSocket opening handshake ('WebSocket connection upgrade failed (400 -ThisserveronlyspeaksWebSocketsubprotocolswamp.2.cbor.batched,wamp.2.cbor,wamp.2.msgpack.batched,wamp.2.msgpack,wamp.2.ubjson.batched,wamp.2.ubjson,wamp.2.json.batched,wamp.2.json)')
2018-03-09 14:54:53+0100 [-] dropping connection to peer tcp4:... with abort=True: WebSocket connection upgrade failed (400 - ThisserveronlyspeaksWebSocketsubprotocolswamp.2.cbor.batched,wamp.2.cbor,wamp.2.msgpack.batched,wamp.2.msgpack,wamp.2.ubjson.batched,wamp.2.ubjson,wamp.2.json.batched,wamp.2.json)
2018-03-09 14:54:53+0100 [-] Stopping factory
<autobahn.twisted.websocket.WebSocketClientFactory object at 0x000002A461F489B0>
2018-03-09 14:55:01+0100 [-] Received SIGINT, shutting down.
2018-03-09 14:55:01+0100 [-] Main loop terminated.
Now, usually, when I get stuck I can find at least something about it on the internet. However, there seems to be little to no information about this (google doesn't even give any results relating WAMP.2).
I imagine that if webSocket servers are using WAMP.2 there must be a way to connect to them, right? If so, why is it so hard to find anything about it?
The code I am working with:
from autobahn.twisted.websocket import WebSocketClientFactory,
WebSocketClientProtocol, connectWS
from twisted.internet import reactor
class EchoClientProtocol(WebSocketClientProtocol):
def sendHello(self):
self.sendMessage("Hello, world!")
def onOpen(self):
self.sendMessage("Hi there")
def onMessage(self, msg, binary):
print("Got echo: " + msg)
reactor.callLater(1, self.sendHello)
if __name__ == '__main__':
import sys
from twisted.python import log
log.startLogging(sys.stdout)
factory = WebSocketClientFactory("wss://api.poloniex.com")
factory.protocol = EchoClientProtocol
connectWS(factory)
reactor.run()