dparlevliet / node.bittrex.api

Node Bittrex API is an asynchronous node.js library for the Bittrex API, the data can be received either via GET request or Stream.
MIT License
253 stars 100 forks source link

How to "unsubscribe" or Subscribe to other markets? #83

Closed D4niFPV closed 6 years ago

D4niFPV commented 6 years ago

Hello,

I am using this:

function updateMarket(dataM) { bittrex.websockets.client(function() { console.log('Websocket connected'); bittrex.websockets.subscribe([dataM], function(data) { if (data.M === 'updateExchangeState') { data.A.forEach(function(data_for) { console.log('Market Update for '+ data_for.MarketName+" Price: "+data_for.Fills[0].Rate); client.emit('marketUpdate', data_for.Fills[0].Rate); }); } }); }); };

Is there a way to unsubscribe and stop receiving updates, and then subscribe to other markets???

aloysius-pgast commented 6 years ago

From my experience, the only way to cancel a subscription is to reconnect (there is no SignalR method to cancel an existing subscription)

dparlevliet commented 6 years ago

@aloysius-pgast is correct, right now that's the only way.

dalaverd commented 6 years ago

How do we reconnect properly without keeping the precedent existing subscription alive?