Closed jprukner closed 4 years ago
Try setting a timeout and see what happens.
Looks like there is no data being passed through so it's just stuck trying to read a frame.
Oh sorry I misread. I'll give your example a shot and let you know.
I tried to run client via go run
instead of using WASM in a browser. Noticed that websocket.NetConn takes context that determines a lifetime of the connection. I pass context that is canceled as soon as the dialer func exits in the example above. I fixed that and the client works when run this way - go run ...
.
It did not solve the issue with the WASM build as it blocks at websocket.Dial call.
I figured something out. When I use this lib with Vugu, it does not work. When I compile to wasm using GOOS=js GOARCH=wasm go build -o main.wasm ...
it works. I will share this with guys from Vugu.
Nice!
Glad there was no bug here 😅
@jprukner are you using the improbable backend with grpcweb.WithWebsockets(true) ?
The server code in your example does not show it so I can't reproduce
@joeblew99 It was not a bug in this library. It was an user error. I tried to use it together with Vugu and used it incorrectly. Please see https://github.com/vugu/vugu/issues/142.
Hey, I've been trying to implement tunnel using this websocket lib. gRPC is supposed to go through the tunnel. I first tried to use https://github.com/dennwc/dom/tree/master/examples/grpc-over-ws. But that example does not compile to WASM with the latest go (1.14) due to changes in
syscall/js
.The error I get in the browser with this library:
It seems to hang here - https://github.com/nhooyr/websocket/blob/master/frame.go#L54. But no error is being printed.
Anyway, here is my implementation heavily inspired by the example from @dennwc:
Server:
Client