Socket data max limit exception

Viewed 1143

I have the following code which gives an exception. Is there a way to either increase the max size limit or to get within the limit please?

 websockets.exceptions.PayloadTooBig[source]
Exception raised when a frame’s payload exceeds the maximum size.

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_instruments",
  "params" : {
    "currency" : "BTC",
    "kind" : "option",
    "expired" : True
  }
}


async def call_api(msg):
  async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
      await websocket.send(msg)
      #while websocket.open:
      response = await websocket.recv()
      data = json.loads(response)
      used_list = [item for item in data['result']]
      used_list = pd.DataFrame.from_records(used_list, exclude=["tick_size","taker_commission","quote_currency","min_trade_amount","maker_commission","contract_size"])#,  columns= ['symbol', 'last_historical_data'])
      return used_list

p = asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

EDIT:

SOLVED by increasing the limit after the URL

websockets.connect('wss://test.deribit.com/ws/api/v2', max_size= 3000000)
0 Answers
Related