Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

GDAX Heartbeat Channel #113

Closed
michaelpszonka opened this issue Sep 23, 2017 · 6 comments
Closed

GDAX Heartbeat Channel #113

michaelpszonka opened this issue Sep 23, 2017 · 6 comments

Comments

@michaelpszonka
Copy link

michaelpszonka commented Sep 23, 2017

Hi there. I'm looking at the documentation and trying to subscribe to the heartbeat channel, with this code:


var websocket = new Gdax.WebsocketClient(
    ['BTC-USD'],
    'wss://ws-feed.gdax.com',
    {
        key: API_KEY,
        secret: API_SECRET,
        passphrase: API_PASSPHRASE,
    },
    { heartbeat: true }
)

  webSocket.on('message', data => {
    console.log(data);
  });

But I keep receiving the following error, despite passing BTC-USD
//error
{ type: 'error',message: 'Failed to subscribe',reason: 'You need to specify at least one product ID for channel heartbeat'

I'm guessing this is more to do with my ignorance on how the code works than anything else. Is there a more appropriate, centralized place to put these comments?

@nengine
Copy link

nengine commented Sep 28, 2017

I did like below and don't have any issues. Are you passing API KEY's properly?

const websocket = new Gdax.WebsocketClient(['LTC-USD']);

websocket.on('message', function(data) { 
	/* work with data */ 
	if (data['type'] == 'received') {
		console.log(data);	
	}
});

@fb55
Copy link
Contributor

fb55 commented Sep 28, 2017

This is a shortcoming of the backwards compatibility for heartbeats. If you authenticate the heartbeat will be processed before the other request, resulting in a failed subscription. This library's heartbeat implementation should be switched to use the heartbeat channel instead.

@nengine
Copy link

nengine commented Oct 12, 2017

Occasionally, GDAX web socket connection will be disconnected even subscribing to heartbeat channel. @fb55 could you please let me know how to reconnect when it is disconnected?

rmm5t added a commit to rmm5t/gdax-node that referenced this issue Nov 30, 2017
- Automatically adds the `heartbeat` channel if not already subscribed
- Removes redundant `keepalive` ping on the socket

Fixes coinbase#113
@rmm5t
Copy link
Contributor

rmm5t commented Nov 30, 2017

Please review #150 for a fix of the heartbeat subscription.

@rmm5t
Copy link
Contributor

rmm5t commented Dec 2, 2017

could you please let me know how to reconnect when it is disconnected?

@nengine You can reconnect by calling WebsocketClient#connect(). For example, in its simplest form:

const client = new Gdax.WebsocketClient(...);
client.on('close', () => client.connect());

Of course, you might want to delay the re-connect and/or retry if the connection if it continues to fail.

rmm5t added a commit to rmm5t/gdax-node that referenced this issue Dec 24, 2017
- Automatically adds the `heartbeat` channel if not already subscribed
- Removes redundant `keepalive` ping on the socket

Fixes coinbase#113
rmm5t added a commit to rmm5t/gdax-node that referenced this issue Dec 25, 2017
- Automatically adds the `heartbeat` channel if not already subscribed
- Removes redundant `keepalive` ping on the socket

Fixes coinbase#113
rmm5t added a commit to rmm5t/gdax-node that referenced this issue Dec 25, 2017
- Automatically adds the `heartbeat` channel if not already subscribed
- Removes redundant `keepalive` ping on the socket

Fixes coinbase#113
@fb55 fb55 closed this as completed in #150 Dec 26, 2017
fb55 pushed a commit that referenced this issue Dec 26, 2017
* Fix heartbeat channel subscriptions

- Automatically adds the `heartbeat` channel if not already subscribed
- Removes redundant `keepalive` ping on the socket

Fixes #113

* Remove heartbeat from OrderbookSync signature
@fb55
Copy link
Contributor

fb55 commented Dec 26, 2017

Fixed in #150

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants