XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.21k stars 512 forks source link

Boilerplate code doesn't work #684

Closed mDuo13 closed 8 years ago

mDuo13 commented 8 years ago

Specifically this version of the boilerplate code, which is included in the latest docs:

const {RippleAPI} = require('ripple-lib');

const api = new RippleAPI({
  server: 'wss://s1.ripple.com' // Public rippled server hosted by Ripple, Inc.
});
api.on('error', (errorCode, errorMessage) => {
  console.log(errorCode + ': ' + errorMessage);
});
api.connect().then(() => {
  /* insert code here */
}).then(() => {
  return api.disconnect();
}).catch(console.error);

When I try to use this code, the script fails out with the following message:

websocket: undefined

If I remove the api.on("error"...) stanza, the code works as expected. I'm not sure who added that code to the boilerplate, but it seems to have broken it, at least in my experience.

mDuo13 commented 8 years ago

Strangely, this error seems to have stopped happening. I can't explain it.