Error Handling ( Max. connection attempts exceeded )
Closed this issue · 2 comments
daniele-bolla commented
Explanation
Hello i would like to ask how can i handle errors in a clean way.
In particular I need to catch
Max. connection attempts exceeded
but it seems that the xrpClient doesn't throw an error ( Maybe i am wrong ).
Also i tried to subscribe to different websocket or eventemitter events, but i am not sure how to handle this situation with them.
Is it possible to get an example?
Code
const main = async (walletAddress: string, network: string) => {
const X_url = network;
const xrpClient = new XrplClient(X_url, {
assumeOfflineAfterSeconds: 15,
maxConnectionAttempts: 4,
connectAttemptTimeoutSeconds: 4,
});
console.log(
xrpClient.eventBus.on("__WsClient_close", () => {
console.log("__WsClient_close");
})
);
xrpClient.on("state", (state) => {
console.log("state", state);
});
xrpClient.on("message", (message) => {
console.log("message", message);
});
xrpClient.on("ledger", (ledger) => {
console.log("Ledger", ledger);
});
xrpClient.on("close", (close) => {
console.log("close", close);
});
const connectionState = xrpClient.getState();
console.log("connectionState", connectionState);
await xrpClient.ready();
const serverInfo = await xrpClient.send({ command: "server_info" });
console.log("serverInfo", serverInfo);
};
(async () => {
try {
await main("walletAddress", "network");
} catch (err) {
console.log(err); //No Error here
}
})();
Error
browser.min.js:13 Uncaught Error: Max. connection attempts exceeded
at s.A (browser.min.js:13)
- Environment Browser
- Version ^1.5.0
N3TC4T commented
daniele-bolla commented
Thanks! @N3TC4T