binance websocket not working in aws instance

Viewed 241

I am trying to get the live prices of crypto tokens in binance.I used websockets for that.

Code:

import websockets
import asyncio

async def hello():
  async with websockets.connect('wss://fstream.binance.com/ws/!markPrice@arr') as websocket:
    print("connected!")
    while True:
      print("Debug")
      greeting = await websocket.recv()
      print(greeting)

  await client.close_connection()

asyncio.run(hello())

This is code working fine in local linux machine (means it's printing the data coming from web socket which is being stored in greeting variable.)

At the same time without changing any code in that, I run that in aws ec2 ubuntu instance,it's doing nothing, just printing connected! and Debug. After that nothing print on console and no any error raised.

I installed web sockets latest version.

1 Answers

I was experiencing a very similar issue. I've found out it has something to do with the newest websocket library release. As a workaround, downgrading from 10.0 to 9.1 is what helped me.

Related