diff --git a/bfxapi/models/Subscription.py b/bfxapi/models/Subscription.py index 331a046..bc32ba4 100644 --- a/bfxapi/models/Subscription.py +++ b/bfxapi/models/Subscription.py @@ -39,7 +39,7 @@ class Subscription: """ if not self.is_subscribed(): raise Exception("Subscription is not subscribed to websocket") - payload = {'event': 'unsubscribe', 'chan_id': self.chan_id} + payload = {'event': 'unsubscribe', 'chanId': self.chan_id} await self._ws.send(json.dumps(payload)) async def subscribe(self): diff --git a/bfxapi/models/subscription.py b/bfxapi/models/subscription.py index 331a046..bc32ba4 100644 --- a/bfxapi/models/subscription.py +++ b/bfxapi/models/subscription.py @@ -39,7 +39,7 @@ class Subscription: """ if not self.is_subscribed(): raise Exception("Subscription is not subscribed to websocket") - payload = {'event': 'unsubscribe', 'chan_id': self.chan_id} + payload = {'event': 'unsubscribe', 'chanId': self.chan_id} await self._ws.send(json.dumps(payload)) async def subscribe(self): diff --git a/bfxapi/websockets/BfxWebsocket.py b/bfxapi/websockets/BfxWebsocket.py index 172d291..e2e304c 100644 --- a/bfxapi/websockets/BfxWebsocket.py +++ b/bfxapi/websockets/BfxWebsocket.py @@ -194,7 +194,10 @@ class BfxWebsocket(GenericWebsocket): await self.subscriptionManager.confirm_unsubscribe(data) async def _system_error_handler(self, data): - self._emit('error', data) + err_string = ERRORS[data.get('code', 10000)] + err_string = "{} - {}".format(ERRORS[data.get('code', 10000)], + data.get("msg", "")) + self._emit('error', Exception(err_string)) async def _system_auth_handler(self, data): if data.get('status') == 'FAILED': diff --git a/bfxapi/websockets/SubscriptionManager.py b/bfxapi/websockets/SubscriptionManager.py index b6be132..df961ee 100644 --- a/bfxapi/websockets/SubscriptionManager.py +++ b/bfxapi/websockets/SubscriptionManager.py @@ -91,7 +91,7 @@ class SubscriptionManager: This function is mostly used to force the channel to produce a fresh snapshot. """ - sub = self.subscriptions_chanid[chan_d] + sub = self.subscriptions_chanid[chan_id] async def re_sub(): await sub.subscribe()