go-socket.io
go-socket.io copied to clipboard
Why do I get "superfluous response.WriteHeader"?
When connecting to the server I get an error:
2020/07/14 16:29:51 http: superfluous response.WriteHeader call from github.com/googollee/go-engine%2eio.(*Server).ServeHTTP (server.go:146)
Code on the server `package main import ( "fmt" "log" "net/http" "github.com/gorilla/mux" "github.com/gorilla/handlers"
socketio "github.com/googollee/go-socket.io"
)
func main() { fmt.Println("Hello world") router := mux.NewRouter() router.HandleFunc("/is-alive", isAlive).Methods("GET")
server, err := socketio.NewServer(nil)
if err != nil {
log.Fatal(err)
}
server.OnConnect("/", func(s socketio.Conn) error {
s.SetContext("")
fmt.Println("connected:", s.ID())
s.Emit("change")
s.Join("bcast")
return nil
})
server.OnEvent("/", "msg", func(s socketio.Conn, msg string) string {
s.SetContext(msg)
fmt.Println("event: msg")
return "recv " + msg
})
server.OnError("/", func(s socketio.Conn, e error) {
fmt.Println("meet error:", e)
})
server.OnDisconnect("/", func(s socketio.Conn, reason string) {
fmt.Println("closed", reason)
})
go server.Serve()
defer server.Close()
router.Handle("/socket.io/", server)
log.Println("Serving at localhost:4444...")
log.Fatal(http.ListenAndServe(":4444", handlers.CORS(handlers.AllowedOrigins([]string{"*"}))(router)))
}
func isAlive(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) }`
same issue. any resolution?
I got this same issue. too bad on my first try. very frustrating. any resolution?
me to ,have any resolution?
me to
me too!
have any resolution?
I followed the examples provided and I get the same error - any advice?
Is there any fixes for this?
any updates?
Is there any fixes for this?
While upgrading to version1.7 getting above error