1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/errors/on-demand-entries-websocket-unavailable.md
JJ Kasper 5d779a0289 Add falling back to fetch based pinging for onDemandEntries (#6310)
After discussion, I added falling back to fetch based pinging when the WebSocket fails to connect. I also added an example of how to proxy the onDemandEntries WebSocket when using a custom server. Fixes: #6296
2019-02-15 22:22:21 +01:00

1.5 KiB

onDemandEntries WebSocket unavailable

Why This Error Occurred

By default Next.js uses a random port to create a WebSocket to receive pings from the client letting it know to keep pages active. For some reason when the client tried to connect to this WebSocket the connection fails.

Possible Ways to Fix It

If you don't mind the fetch requests in your network console then you don't have to do anything as the fallback to fetch works fine. If you do, then depending on your set up you might need configure settings using the below config options from next.config.js:

module.exports = {
  onDemandEntries: {
    // optionally configure a port for the onDemandEntries WebSocket, not needed by default
    websocketPort: 3001,
    // optionally configure a proxy path for the onDemandEntries WebSocket, not need by default
    websocketProxyPath: '/hmr',
    // optionally configure a proxy port for the onDemandEntries WebSocket, not need by default
    websocketProxyPort: 7002,
  },
}

If you are using a custom server with SSL configured, you might want to take a look at the example showing how to proxy the WebSocket connection through your custom server