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

wasm not working for unknown reason #421

Closed
nhooyr opened this issue Nov 13, 2023 · 6 comments
Closed

wasm not working for unknown reason #421

nhooyr opened this issue Nov 13, 2023 · 6 comments

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Nov 13, 2023

          While the Go team decides how (or whether?) to handle this, is there a workaround ? 

My execution environment:

  • server: go1.21.4 darwin/arm64
  • client: Safari 17.1 running a wasm client compiled with go1.21.4 (GOOS=js GOARCH=wasm)

When the wasm client tries to connect, the server gets this error from websocket.Accept(w,req,nil):

failed to accept WebSocket connection: WebSocket protocol violation: Connection header "keep-alive" does not contain Upgrade

When package websocket is compiled for wasm, the field websocket.DialOptions.HTTPHeader is not available, so I cannot add the required header. This appears to be a limitation of the Javascript WebSocket API, or of how the API is used.

I presume this is all related to issue 373.

But it is possible that I am on the wrong track and have no idea what I am doing wrong.

I would be grateful for any guidance.

Originally posted by @fbaube in #4 (comment)

@nhooyr
Copy link
Contributor Author

nhooyr commented Nov 13, 2023

@fbaube Not related to HTTP/2.

The browser automatically adds such headers as necessary. Do you have a proxy between the client and server? Any middleware before you call websocket.Accept that might be interfering?

@fbaube
Copy link

fbaube commented Nov 13, 2023

Do you have a proxy between the client and server? Any middleware before you call websocket.Accept that might be interfering?

No proxy, no middleware. I am running the server and Safari on the same machine, and the URL is to localhost.

Not related to HTTP/2.

I can add that for completeness, I tried methods (documented in stdlib http) to disable HTTP/2, and in both cases I still got the identical error about the missing keep-alive header:

  • Invoke the server with GODEBUG=http2server=0 (and of course also GODEBUG=http2client=0, because why not)
  • Set the server's TLSNextProto to a non-nil map (by following this example)

@nhooyr
Copy link
Contributor Author

nhooyr commented Nov 13, 2023

Is it possible for you to upload your code?

@fbaube
Copy link

fbaube commented Nov 14, 2023

I'll try to make a minimal demo of the bug. I might find that something else is gumming up the works.

@fbaube
Copy link

fbaube commented Nov 14, 2023

I withdraw this issue.

I had not used my code for months, and it was not updated as needed. In particular, wasm_exec.js was out of sync.

I have updated it to be the proper version, and it is now renamed to wasm_exec_21_4.js

My apologies.

@nhooyr
Copy link
Contributor Author

nhooyr commented Nov 14, 2023

Awesome!

@nhooyr nhooyr closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants