iris icon indicating copy to clipboard operation
iris copied to clipboard

[BUG] mvc websocket can't work

Open ghost opened this issue 4 years ago • 0 comments

https://github.com/kataras/iris/blob/master/_examples/mvc/websocket/main.go

I referenced this example and it didn't work. I copied the code in the example and it didn't work. Also need this is the expired example.

this's go.mod from my project:

module xxx

go 1.14

require ( github.com/gorilla/websocket v1.4.2 github.com/kataras/iris/v12 v12.2.0-alpha2.0.20210427211137-fa175eb84754 github.com/kataras/neffos v0.0.18 )

client code:

func TestUserNotifyCtrl_OnNamespaceConnected(t *testing.T) {
	cli, _, err := websocket.DefaultDialer.Dial("ws://localhost:8080/websocket", nil)

	if err != nil {
		t.Fatal(err)
	}
	defer cli.Close()
	fmt.Println(cli.WriteMessage(websocket.TextMessage, []byte("hello")))
}

ghost avatar May 21 '21 03:05 ghost