I'm using x.net.websocket
to read data from a websocket.
The data is relatively large. When I read it, I can't read it completely, so it is cut off.
Is there any way to solve it?
func receiveWebsocket(ws *websocket.Conn) error {
for {
var msg = make([]byte, 1024*1024) // 1024kb
m, err := ws.Read(msg)
if err != nil {
log15.Error("ws read error", "error", err)
return err
}
fmt.Println("length ---",m, string(msg))
response := string(msg[:m])
assignmentWebsocket(response)
}
}
According to the log, the m
value is always 4092, even if msg
is very large.