Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Cannot connect to websocket with wrangler dev #1910

Closed
universse opened this issue May 4, 2021 · 6 comments · Fixed by #2153
Closed

Cannot connect to websocket with wrangler dev #1910

universse opened this issue May 4, 2021 · 6 comments · Fixed by #2153
Labels
dev `wrangler dev` feature Feature requests and suggestions

Comments

@universse
Copy link

🐛 Bug report

Describe the bug

I keep getting this message when trying to connect to websocket using wrangler dev. Non-websocket routes work fine though.

[2021-05-04 22:54:59] GET dev-bug.ulrjch.workers.dev/ws HTTP/1.1 400 Bad Request
[2021-05-04 22:55:08] GET dev-bug.ulrjch.workers.dev/ HTTP/1.1 200 OK

image

Reproduce the bug

  1. Clone https://github.com/universse/wrangler-bug
  2. Enter account_id in wrangler.toml
  3. Run wrangler dev
  4. Open index.html
  5. Above error messages would appear in terminal.

Optional: It works fine when published.

  1. Run wrangler publish
  2. Replace websocket link in index.html
  3. Open index.html
  4. Websocket connection is successful.

Expected behavior

Should be able to connect to websocket using wrangler dev.

Environment and versions

Fill out the following information about your environment.

  • operating system: Windows 10 Home
  • output of wrangler -V: wrangler 1.16.0-durable-objects-rc.0
  • output of node -v: v15.10.0
  • content of wrangler.toml: per repo
@universse universse added the bug Something isn't working label May 4, 2021
@universse
Copy link
Author

I have tried type: "webpack" for wrangler.toml as well. It doesn't work still.

@Electroid
Copy link
Contributor

We currently do not support WebSocket debugging in wrangler dev, but obviously we should. Will get back to you as we figure out the complexity for this addition.

@Electroid Electroid added dev `wrangler dev` feature Feature requests and suggestions and removed bug Something isn't working labels May 4, 2021
@dan-online
Copy link

Hey it's September now, how's this doing? I've found the same issue with wrangler dev and can confirm it only works when published.

$ wrangler -V
wrangler 1.19.3

@threepointone
Copy link
Contributor

We've scheduled to fix this in q4 (ie - before the end of this year) Until then, the recommendation is to use miniflare #2079 (comment) Sorry for the delay on this, we'll fix it soon.

@seeekr
Copy link

seeekr commented Jan 6, 2022

Just a heads up to maybe update the note at https://developers.cloudflare.com/workers/learning/using-websockets#writing-a-websocket-server in case this should already be fixed in production!

@threepointone
Copy link
Contributor

Good catch! sent a PR that removes the message cloudflare/cloudflare-docs#3082. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dev `wrangler dev` feature Feature requests and suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@threepointone @seeekr @Electroid @universse @dan-online and others