Open
Description
Hello 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