go-socket.io icon indicating copy to clipboard operation
go-socket.io copied to clipboard

How can I get conn on Error event? I need timeout event when pingtimout occur....

Open Azure1029 opened this issue 6 years ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Brief code to reproduce the behavior.

Expected behavior A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Go version: [e.g. v1.11]
  • Server version [e.g. go-socket.io v1.4]
  • Client version [e.g. socket.io v1.4]

Additional context Add any other context about the problem here.

Azure1029 avatar Apr 19 '19 04:04 Azure1029

I meet the same problem. I registe the error handler like this:

	mysocketio.OnError("", func(err error) {
		log.Errorf("error=%+v", err)
		ctrl.DealError("", err)
	})

// ... github.com/googollee/go-socket.io/conn.go:142~154
func (c *conn) serveError() {
	defer c.Close()
	for {
		select {
		case <-c.quitChan:
			return
		case msg := <-c.errorChan:
			if handler := c.namespace(msg.namespace); handler != nil {
				handler.onError(msg.error)
			}
		}
	}
}

When error event is triggered, I can get the call stack, but I don't known which Conn this error beyond to.

[ERRO] [2019/05/06 19:29:00.894] [controller.go:490 DealError] DealError, err: websocket: close 1006 (abnormal closure): unexpected EOF DealError main.(*WGController).DealError ../controller.go:490 main.setupSocketIOServer.func3 ../main.go:93 vendor/github.com/googollee/go-socket%2eio.(*conn).serveError .../vendor/github.com/googollee/go-socket.io/conn.go:150 runtime.goexit C:/Go/src/runtime/asm_amd64.s:1337

ardingchen avatar May 06 '19 11:05 ardingchen