Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket is closed before the connection is established #51028

Open
1 task done
foxhound87 opened this issue Jun 9, 2023 · 9 comments
Open
1 task done

WebSocket is closed before the connection is established #51028

foxhound87 opened this issue Jun 9, 2023 · 9 comments
Labels
bug Issue was opened via the bug report template.

Comments

@foxhound87
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000
    Binaries:
      Node: 16.19.1
      npm: 8.19.3
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.4
      eslint-config-next: 13.4.3
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

/

To Reproduce

Configure a websocket connection in nextjs.

Describe the Bug

Console log report:

WebSocket connection to 'ws:<URL>/_next/webpack-hmr' failed: WebSocket is closed before the connection is established.

Expected Behavior

websocket should work as expected

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@foxhound87 foxhound87 added the bug Issue was opened via the bug report template. label Jun 9, 2023
@daneseuwu
Copy link

[UpdateServer]: error sending to WebSocket: IO error: An established connection was aborted by the software in your host machine. (os error 10053): An established connection was aborted by the software in your host machine. (os error 10053)

@catter1
Copy link

catter1 commented Jun 11, 2023

Can confirm, am getting the same issue. This started after I updated Next.js (and a bunch of other packages) from 13.2.4 to 13.4.5. Comparing to OP, here's my relevent information:

Operating System/etc:
   Platform: Ubuntu
   Arch: x86_64
   Version: 22.04.2 LTS
   Browser: Ungoogled Chromium
Binaries:
   Node: 18.13.0
   npm: 9.7.1
   Yarn: N/A
   pnpm: N/A
Relevant packages:
   next: 13.4.5
   eslint-config-next: 13.4.5
   react: 18.2.0
   react-dom: 18.2.0
   typescript: 5.1.3
All Packages

[email protected] /path/to/my/project
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Notes

  • I am not using WebSocket directly in any way in my code.
  • This is being ran as development on my personal machine. No custom server.
  • It appears to be blocking calls from my server to the client? Not entirely sure if it's related yet, but I discovered this issue by trying to troubleshoot the API.
  • This error occurs on every single page on my site.

Things I have tried

As I am somewhat new to Next.js, I am not sure what other information from my project would be of use. Please let me know, and I will provide it. Thank you for your time, I hope this either gets resolved or a solution is found.

image

@pkhodaveissi
Copy link

Same issue here.
Getting: WebSocket connection to 'ws:<URL>/_next/webpack-hmr' failed: WebSocket is closed before the connection is established.

We had pages directory and now we have introduced app directory routing with this structure:

image

@mortyccp
Copy link

mortyccp commented Jul 3, 2023

I think this is related to this pull request #49805

@artitudinale1
Copy link

The PR has been merged but I'm still having this issue, seems on Window OS but not in Ubuntu, is there any fix?

@tomchentw
Copy link

I'm having the same issue with the development server on [email protected]

@sinapirani

This comment has been minimized.

@tzelon-cypator
Copy link

I have the same issue, downgrading to [email protected] works.
I have app and pages directories.

@meotimdihia
Copy link

If you are using nginx, you need to add this configuration:
https://nextjs.org/docs/pages/building-your-application/upgrading/version-12#hmr-connection-now-uses-a-websocket

location /_next/webpack-hmr {
    proxy_pass http://localhost:3000/_next/webpack-hmr;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

10 participants