n0mad01 / node.bittrex.api

No longer maintained
MIT License
183 stars 187 forks source link

Setting the `connected` websocket service handler prevents `updateExchangeState` messages from being received #52

Open mhuggins opened 7 years ago

mhuggins commented 7 years ago

I'm not sure if this is the right place for this, but I have no idea where else to ask. I've been doing development with this package against the Bittrex API/websocket endpoints all day. I suddenly am no longer getting "updateExchangeState" messages via the websocket. (I'm still receiving "updateSummaryState" messages just fine.) I'm wondering if something changed or broke on their end, something broke in this package (I don't think that's the case since I tried various versions), or if perhaps I got throttled.

mhuggins commented 7 years ago

Never mind, I broke something on my end. Some old code I rolled back to still works as expected. I'll update this issue when I figure out what I broke in case it helps someone else.

mhuggins commented 7 years ago

Okay, I tracked this down, and I think it's worth reopening. The documentation mentions that there's a connected serviceHandler. I was using this for logging, but by doing so, it removed some built-in logic for subscribing to all the exchange state messages. I also noticed that there is a reference to a bound service handler, but I don't see that being called anywhere.

It seems like there should a way to add a connected serviceHandler without losing the logic defined by calling websockets.subscribe(tickers).

n0mad01 commented 7 years ago

the connected serviceHandler is firmly intertwined with the subscribe call in order to simlpyfy the process.

right at the moment you'll need to call the bare client and define 'connected' by yourself

var websocketsclient = bittrex.websockets.client();

websocketsclient.serviceHandlers.connected = function (conn) {}
dparlevliet commented 7 years ago

It probably wouldn't be a bad idea to have an event emitter so people can perform their own logic on events without interrupting the normal logic. I assume this is what you're asking for @mhuggins?

mhuggins commented 7 years ago

@dparlevliet Exactly.

dparlevliet commented 7 years ago

btw this has been implemented in https://github.com/dparlevliet/node.bittrex.api/issues/1