API fails to connect after some time.
See original GitHub issueWhen 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:
- Created 4 years ago
- Comments:7 (6 by maintainers)
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.
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.