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.

Possible fix for webpackHotDevClient disconnecting from server.

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ianschmitzcommented, Jan 27, 2020

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.

1reaction
drather19commented, Dec 6, 2019

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 from sockjs done in https://github.com/facebook/create-react-app/pull/7988?

Read more comments on GitHub >

github_iconTop 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 >

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