Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const CoinbasePro = require('coinbase-pro');
  2. var coinbaseWs = '';
  3.  
  4. function connect() {
  5. coinbaseWs = new CoinbasePro.WebsocketClient(
  6. ['BTC-USD'],
  7. 'wss://ws-feed.pro.coinbase.com',
  8. {
  9. key: 'xxxx',
  10. secret: 'xxxx',
  11. passphrase: 'xxxx',
  12. },
  13. { channels: ['matches'] }
  14. );
  15.  
  16. coinbaseWs.on('message', async data => {
  17. console.log(data)
  18. });
  19.  
  20. coinbaseWs.on('error', err => {
  21. console.error("Connection with Coinbase websocket failed with error: " + err);
  22. console.log("Error stack trace: " + err.stack);
  23. });
  24.  
  25. coinbaseWs.on('close', () => {
  26. console.error("Connection with Coinbase websocket closed!");
  27. });
  28. }
  29.  
  30. connect();
  31.  
  32. Error: read ECONNRESET
  33. File "internal/stream_base_commons.js", line 167, in TLSWrap.onStreamRead
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement