XRPLF / xrpl.js

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

timeout option is not working #1196

Closed koresar closed 3 years ago

koresar commented 4 years ago
const api = new RippleAPI({ server: "wss://s1.ripple.com", timeout: 60000 });
api.connect(); // <-- rejects in 2000 ms

The api.connect() does not respect the timeout option and rejects after 2000 ms. Here is the error message:

"Error: connect() timed out after 2000 ms. If your internet connection is working, the rippled server may be blocked or inaccessible."

Help!

intelliot commented 4 years ago

The connection timeout option is connectionTimeout (instead of timeout).

Why is it taking more than 2 seconds to connect to rippled -- is that what you expect? (Is your internet connection really that slow?)

koresar commented 4 years ago

The machine which is connecting to the rippled is very weak. It takes about 2.1 seconds to connect to r1 over the pacific ocean using websockets. 😅

On Thu., 30 Jan. 2020, 20:22 Elliot Lee, notifications@github.com wrote:

This is a bug (the timeout option isn't working) and we should fix it. But why is it taking more than 2 seconds to connect to rippled -- is that what you expect? (Is your internet connection really that slow?)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ripple/ripple-lib/issues/1196?email_source=notifications&email_token=AAMMELYNYBUGTMPQBT75UT3RAKL4VA5CNFSM4KNRW2NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKKIZLY#issuecomment-580160687, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMMEL62HWPO64AERUKSMF3RAKL4VANCNFSM4KNRW2NA .

intelliot commented 4 years ago

Thanks. I think we should make the timeout option work, and we should also increase the default timeout to 5 seconds (5000 ms).

nickewansmith commented 4 years ago

Would it make sense to remove timeout and add requestTimeout and connectionTimeout to ripple api options?, with the default for connectionTimeout set to 5000ms.

intelliot commented 4 years ago

I’m happy either way — I’ve not needed to adjust the timeouts personally but I can see that being useful for some slower machines/networks.

kincaidoneil commented 4 years ago

I'm also experiencing this error, NotConnectedError: Error: connect() timed out after 2000 ms. If your internet connection is working, the rippled server may be blocked or inaccessible. when running a test using S1 from DigitalOcean East.

It looks like the connectionTimeout property adjusts this (and is included in the TypeScript types), but doesn't work because it's not included in the schema here.

In the meantime, this works for me:

// @ts-ignore
rippleClient.connection._config.connectionTimeout = 10000
southbite commented 4 years ago

Is this not a duplicate of issue #1174 ?

koresar commented 4 years ago

I wouldn't call these duplicates. But you one can be causing another.