Description
I have been using the NetConn function to create a net.Conn from a websocket.Conn.
My client is then also written using the same library proxies between a websocket and stdin/stdout (not using NetConn, just (error handling removed for clarity)
for {
_, r, _:= c.Reader(ctx)
_, _ = io.Copy(os.Stdout, r)
}
By default, the message reader has a limit of 32768 per message, however the net.Conn wrapper produced by NetConn doesn't limit what it sends, it just writes everything from each Write call into a message and sends it on the websocket.
This means that without a call to c.SetReadLimit I'm going to get the socket being closed when the server writes something bigger than 32k to the socket.
I'm not in control of the server, I'm creating a net.Conn that wraps the websocket and then passing it to a third party library. I'm proxying a protocol over a websocket using the equivalent of "netcat" at the client.
Given that there is a read limit on the client, would it make sense to add a write limit to the net.Conn wrapper so that it will chop the data up into messages of at most that size? Otherwise my only real option seems to be to call s.SetReadLimit(math.MaxInt64-1) to effectively remove the read limit (passing math.MaxInt64 results in an overflow as SetReadLimit adds one to the passed in value).
Thanks.