MCPcopy Create free account
hub / github.com/ccxt/ccxt / handle_ws_error

Method handle_ws_error

python/ccxt/pro/binance.py:4288–4324  ·  view source on GitHub ↗
(self, client: Client, message)

Source from the content-addressed store, hash-verified

4286 self.handle_positions(client, message)
4287
4288 def handle_ws_error(self, client: Client, message):
4289 #
4290 # {
4291 # "error": {
4292 # "code": 2,
4293 # "msg": "Invalid request: invalid stream"
4294 # },
4295 # "id": 1
4296 # }
4297 #
4298 id = self.safe_string(message, 'id')
4299 rejected = False
4300 error = self.safe_dict(message, 'error', {})
4301 code = self.safe_integer(error, 'code')
4302 msg = self.safe_string(error, 'msg')
4303 try:
4304 self.handle_errors(code, msg, client.url, '', {}, self.json(error), error, {}, {})
4305 except Exception as e:
4306 rejected = True
4307 # private endpoint uses id
4308 client.reject(e, id)
4309 # public endpoint stores messageHash in subscriptions
4310 subscriptionKeys = list(client.subscriptions.keys())
4311 for i in range(0, len(subscriptionKeys)):
4312 subscriptionHash = subscriptionKeys[i]
4313 subscriptionId = self.safe_string(client.subscriptions[subscriptionHash], 'id')
4314 subscription = self.safe_string(client.subscriptions[subscriptionHash], 'subscription')
4315 if id == subscriptionId:
4316 client.reject(e, subscriptionHash)
4317 if subscription is not None:
4318 del client.subscriptions[subscription]
4319 if not rejected:
4320 client.reject(message, id)
4321 # reset connection if 5xx error
4322 codeString = self.safe_string(error, 'code')
4323 if (codeString is not None) and (codeString[0] == '5'):
4324 client.reset(message)
4325
4326 def handle_event_stream_terminated(self, client: Client, message):
4327 #

Callers 1

handle_messageMethod · 0.95

Calls 8

handle_errorsMethod · 0.95
safe_stringMethod · 0.80
safe_dictMethod · 0.80
safe_integerMethod · 0.80
rejectMethod · 0.65
rangeFunction · 0.50
jsonMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected