coinbase / coinbase-pro-node

DEPRECATED — The official Node.js library for Coinbase Pro
Apache License 2.0
844 stars 316 forks source link

Websocket error #17

Closed adamrabie closed 7 years ago

adamrabie commented 7 years ago

When following documentation to start websocket with gdax get his error:

TypeError: must start with number, buffer, array or string

previous coinbase-exchange module doesn't have this error so i'm downgrading back to that.

mihar commented 7 years ago

Thanks for reporting, we will investigate

lejeunerenard commented 7 years ago

This error is caused when no authentication is given and auth.secret is attempted to be coerced/created as a Buffer. #19 fixes this issue allowing the subscribe message to be sent with or without being signed.

michelem09 commented 7 years ago

How can I use the websocket authenticated?

lejeunerenard commented 7 years ago

@michelem09 Websocket Authentication can be done when creating the websocket client by passing the authentication object as the third argument like so:

var Gdax = require('gdax');
var authentication = {
  secret: 'SECRET',
  key: 'KEY',
  passphrase: 'password'
};
var websocket = new Gdax.WebsocketClient(null, null, authentication);
websocket.on('message', function(data) { console.log(data); });

For more information on setting up authentication, checkout the API docs.

mrstock commented 7 years ago

Can you please explain what's the difference between websocket authenticated and not ? Any difference on the received messages ?

Thank you

lejeunerenard commented 7 years ago

@mrstock it adds a few fields to the subscribe message including a signature. Why it passes these I am not sure since the documents never state to do so and there is no reason I can think of to authenticate the subscribe message.

@mihar can you shed some light on this?

mihar commented 7 years ago

It mainly expands messages that are geared towards you. We will add documentation about it soon.