question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API-WS: disconnected from ws://rpc.polkadot.io: 1006:: connection failed

See original GitHub issue

I am trying to connect to the public node using the @polkadot/api npm module.

Version: "@polkadot/api": "^2.3.1"

Node Version: v12.16.2

This is my code

// Import
const { ApiPromise, WsProvider } = require('@polkadot/api');

const wsProvider = new WsProvider('ws://rpc.polkadot.io');

const main = async () => {
    const api = await ApiPromise.create({ provider: wsProvider });
    await api.isReady;
    // Do something
    console.log(api.genesisHash.toHex());
};

main();

Due to this error I am unable to use the substrate-api-sidecar docker image.

Thanks.

EDIT The error is same for both urls ws://rpc.polkadot.io and wss://rpc.polkadot.io.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
schadokarcommented, Oct 22, 2020

Thank you. I think it was some network issue. Now, it is working.

0reactions
polkadot-js-botcommented, Jun 3, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API dies if querying after disconnect · Issue #2257 - GitHub
Reproduce: await api.disconnect() await api.derive.staking. ... disconnected from wss://kusama-rpc.polkadot.io: 1006:: connection failed ...
Read more >
API-WS: disconnected from ws://127.0.0.1:9946: 1006 ...
I'm trying to connect local node running on my pc using polkadot.js library in react.js(browser). I'm pasting my code in below snippet and ......
Read more >
Connect via WSS to Polkadot Full Noder running on local ...
But when I run it on my local machine to point to wss://192.168.2.254:9944, the output is connection failed with code 1006:.
Read more >
How to fix connection issues on polkadot.js
You may encounter the error "Waiting to make a connection to the remote endpoint and finishing API initialization".
Read more >
Create an instance - polkadot{.js}
All API instances implement an EventEmitter interface, with on handlers, which emit connected , disconnected , ready and error events, allowing you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found