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 fails to connect after some time.

See original GitHub issue

When an application using the Polkadot-JS API is not connected for a long time, it fails to be able to connect at a later point until you restart the whole browser.

Hard to say exactly what is going on here, but I have seen this in multiple cases, across multiple people’s computers.

Usually what is happening is that we are doing Substrate development. We connect a UI which uses the Polkadot-JS API (either Polkadot-JS Apps or substrate-front-end-template).

Upon initial connection to our local node, everything works as expected. Later the node is stopped so that users can do development.

Some time later, it may involve putting the computer to sleep (not sure), the user runs their local node again, and waits for the UI to connect to their node…

Nothing happens.

They refresh the page, nothing happens.

The error message is the standard one that it cannot find a node:

Provider.js:236 WebSocket connection to 'ws://127.0.0.1:9944/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
connect @ Provider.js:236
(anonymous) @ Provider.js:112
index.js:1375 2019-10-02 18:31:42          API-WS: disconnected from ws://127.0.0.1:9944 code: '1006' reason: ''

Only when you close the browser process, and then restart it, does it start working again, and connects no problem.

Both times I have seen it was using Chrome and on a Mac OSX computer.

Will be looking out for reproduction steps.

CC @hcastano

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jacogrcommented, Oct 4, 2019

The “Unknown Reason” is not helpful. However all browsers, due to security concerns, do not report any specific errors for WSS connection - as per RFC. So it can be, well, anything.

The fact that a page refresh doesn’t connect but a re-open browser does, makes me think this is something OS or browser-related. (For instance, there is a leak in WASM usage in Chrome, which can only be worked around with a new tab)

One thing to try - when it happens again, don’t close the browser, however create a new tab, see if it recovers.

0reactions
polkadot-js-botcommented, May 31, 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

Calls to an API fails after some time when multiple users are ...
The calls to the api are made from a web application and it is working fine for some time but then immediately after...
Read more >
API Connect error "Backside connection failed" when calling ...
Open your APIC management portal. · Expand the menu, and select Drafts. · Select the APIs tab, and open the API in question....
Read more >
Troubleshooting API Connection Issues - Service Objects Blog
Still having a tough time connecting to our services? Check through a command prompt on the server in question to ensure you can...
Read more >
REST API calls sometimes return "Connection Failure" - Telerik
Hi David, Based on the error response sent, it seems that by some reason the invoked requests doesn't reach to our servers at...
Read more >
Resolve connection issues with API Gateway private ... - AWS
If the API request doesn't produce any CloudWatch logs after logging is activated, then the request didn't reach the endpoint. If your API...
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