-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Thanks for your great project!!!
There has some problem when i use iris 11.1.1, i was setting MaxMessageSize when websocket.New, i try to send a data larger than this size, the websocket channel will be disconnected by itself , but no error information can be get.
I can't find any information, and I can't see the method from the source code. After testing several methods, there is no effect, so I have to ask questions here.
Hope to get some advice, sorry for my pool english......
There are some code method which i try
func main() {
app := iris.Default()
mvc.Configure(app.Party("/ws"), websocket.ConfigureWS)
.....
}func ConfigureWS(m *mvc.Application) {
ws := websocket.New(websocket.Config{MaxMessageSize: 3145728, ReadTimeout: time.Minute,
Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) {
util.GetLog().Error("websocket new err", status, reason.Error())
}})
ws.OnConnection(func(c websocket.Connection) {
fmt.Println(c.Context())
fmt.Println(c)
fmt.Println(ws.GetConnections())
c.OnDisconnect(func() {
fmt.Println(c)
})
c.OnError(func(e error) {
fmt.Println(e.Error())
})
})
m.Register(
ws.Upgrade, ws,
)
websocketController := new(WebsocketListen)
m.Handle(websocketController)
}
type WebsocketListen struct {
Ctx iris.Context
Conn websocket.Connection
WS *websocket.Server
}func (c *WebsocketListen) Get() {
c.WS.OnConnection(func(c websocket.Connection) {
fmt.Println(c.Err())
})
c.Conn.OnError(func(e error) {
fmt.Println(e)
})
//fmt.Println(c.Conn.ID())
c.Conn.OnLeave(c.onLeave)
c.Conn.OnMessage(c.OnMessage)
c.Conn.OnError(func(err error) {
fmt.Println(err.Error())
})
c.Conn.OnDisconnect(func() {
fmt.Println(c.Conn.Err())
})
c.Conn.Wait()
}
func (c *WebsocketListen) onLeave(roomName string) {
fmt.Println(c.Ctx.Request().Context().Err())
util.GetWsLog().Debug("Leave channelId", c.Conn.ID())
}Thanks again.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels