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: response does not implement http.Hijacker #12

Open
TommasoAmici opened this issue Jul 20, 2021 · 1 comment
Open

websocket: response does not implement http.Hijacker #12

TommasoAmici opened this issue Jul 20, 2021 · 1 comment
Labels
question Further information is requested

Comments

@TommasoAmici
Copy link

TommasoAmici commented Jul 20, 2021

Hi, I'm trying to use this library with WebSockets using https://github.com/gorilla/websocket, but I get this error when the server attempts to upgrade the connection.

websocket: response does not implement http.Hijacker

If I revert to the standard library with

mux := http.NewServeMux()

everything works fine

@kataras
Copy link
Owner

kataras commented Nov 16, 2021

Hello @TommasoAmici sorry for the delay,

You need to cast ResponseWriter to *muxie.Writer and then get its standard writer, example code:

	mux.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
		serveWs(hub, w.(*muxie.Writer).ResponseWriter, r)
	})

Example: https://github.com/kataras/muxie/tree/master/_examples/14_websocket

@kataras kataras added the question Further information is requested label Nov 16, 2021
kataras added a commit that referenced this issue Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants