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

tcp protocol not avalible (websocket) #14

Closed
DAT4 opened this issue Mar 28, 2021 · 0 comments
Closed

tcp protocol not avalible (websocket) #14

DAT4 opened this issue Mar 28, 2021 · 0 comments

Comments

@DAT4
Copy link

DAT4 commented Mar 28, 2021

Hi. I made a online multiplayer game in Ebiten, and I wanted to use wasmserve to make it possible to run the game from a browser.

  1. First I wanted to download the map with a http.Get("https://domain.ext/map.json"), but I got a CORS error, I tried using the -allow-origin "*" flag to get around it. It didnt help anything. So I hardcoded the map into the code and then I could start the application.

  2. Next step is to login. So I am writing my username and password on the screen and everything works. I send the credentials and I receive the Token.

  3. The next step is to connect to the websocket connection in the backend. I am using gorilla/websocket and I write

u := "ws://localhost:8056/join"
log.Printf("connecting to %s", u)
header := http.Header{}
header.Add("Authorization", "bearer "+token
websocket.DefaultDialer.Dial(u, header)

wasm gives me this error:

2021/03/28 14:05:31 connecting to ws://localhost:8056/join wasm_exec.js:51:14
2021/03/28 14:05:31 dial tcp: Protocol not available

And my program crashes.

Is this because wasmserve does not support websocket or am I doing something wrong?

Best regards Martin Maartensson.

EDIT:
I just found out that its actually gorilla/websocket which doesn't support wasm, so an alternative could probably be to use nhooyr/websocket instead of gorilla/websocket.

@DAT4 DAT4 closed this as completed Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant