Possible fix for webpackHotDevClient disconnecting from server.
See original GitHub issueHello I would like to submit a fix for the issue people are having with the websocket in webpackHotDevClient.js disconnecting from the server. The websocket is timing out after some time, so we simply ping the server periodically to prevent it from timing out. Here is the code I’ve been using.
// Ping the server to prevent the client from disconnecting
var ping = function() {
if (connection && (connection.readyState === connection.OPEN)) {
connection.send("ping");
setTimeout(ping, 3000);
}
};
connection.onopen = function() {
if (typeof console !== 'undefined' && typeof console.info === 'function') {
console.info(
'The development server has connected.'
);
}
ping();
};
I have a branch ready here. I can submit a PR. https://github.com/vibelife/create-react-app/blob/master/packages/react-dev-utils/webpackHotDevClient.js#L85
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:13 (7 by maintainers)
Top Results From Across the Web
When using create-react-app why does the development ...
The development server has disconnected. Refresh the page if necessary. I looked at one of the other SO posts and my problem seems...
Read more >React development server disconnected problem
When ı refresh my page. Logged the console this message " The development server has disconnected. Refresh the page if necessary".
Read more >Fix "Disconnected from server" & Connection Issues - YouTube
Trying to get Warhammer 40000: Darktide to work properly? Keep getting disconnected ? Well, this video runs through some simple solutions, ...
Read more >Disconnect clients when sign-in hours expire
Enable the Microsoft network server: Disconnect clients when logon hours expire setting. Potential impact. If sign-in hours aren't used in your ...
Read more >Disconnecting from an Administration Server
In the console tree select the node corresponding to the Administration Server that you want to disconnect. In the context menu of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We upgraded to the WS implementation to fix some other issues, so i doubt we’ll be going back to the legacy sockjs implementation as WS is the path forward. If webpack-dev-server isn’t responsive we can potentially patch things up in CRA to help.
I created an upstream issue at https://github.com/webpack/webpack-dev-server/issues/2403.
I am experiencing the same issue. If I don’t make any code edits, the dev server web socket connection times out after 5 minutes. Is this related to the switch to native
ws
transport fromsockjs
done in https://github.com/facebook/create-react-app/pull/7988?