bennycode / coinbase-pro-node

Coinbase API written in TypeScript and covered by tests.
https://bennycode.com/coinbase-pro-node
MIT License
255 stars 62 forks source link

Q: onopen does not trigger for authenticated socket in container #738

Closed alexander-hagen closed 2 years ago

alexander-hagen commented 2 years ago

The WebSocketEvent.ON_OPEN event does not trigger on an authenticated connection, when running in a docker container. The event does trigger when not running in a container. There are no errors. Authentication values are identical. For public sockets the ON_OPEN event is triggered both in a docker container, and outside.

const auth={ apiKey: mykey, apiSecret: mysecret, passphrase: mypass, useSandbox: false}; api.privateAPI=new CoinbasePro(auth);

api.privateAPI.ws.on(WebSocketEvent.ON_OPEN, async () => { console.log("Socket open"); });

api.privateAPI.ws.connect();

Any ideas why this is working outside a docker container, but only for authenticated connections it is not inside a docker container?

alexander-hagen commented 2 years ago

This seems to be due to a missing dependency that is not listed in package.json or package-lock.json as copying the full node_modules into the container instead of a npm install solves the issue.

bennycode commented 2 years ago

This project does not have a package-lock.json file, so I suggest using it by installing all dependencies using yarn.