I’m trying to use a new cryptocurrency exchange called Bybit. As a simple starting point I tried the following code just to check if there is something wrong with WebSocket connections in general.
import sys from twisted.python import log from twisted.internet import reactor, ssl from autobahn.twisted.websocket import WebSocketClientFactory, WebSocketClientProtocol, connectWS class Protocol(WebSocketClientProtocol): def onOpen(self): print("Connected!") def onMessage(self, payload, isBinary): print(payload.decode("utf8")) if __name__ == "__main__": log.startLogging(sys.stdout) #wss://stream.binance.com/stream factory = WebSocketClientFactory("wss://stream.bybit.com/realtime") factory.protocol = Protocol contextFactory = ssl.ClientContextFactory() connectWS(factory, contextFactory) reactor.run()
But when I try that code I get the following error: SSL error: wrong version number (in ssl3_get_record)
When I replace the URL with the URL of Binance (in the commented line) everything works fine.
I tried the same code on different systems with different operating systems but that solved the issue. Then I tried to use a different pyOpenSSL version but that didn’t work either.
Does anyone know what the exact issue could be?
Thank you for every help!