Closed spy16 closed 3 months ago
Hey, no idea about gnet
, maybe @panjf2000 has some ideas.
I have created a very fast and modular framework and is used in production in our company. You can check how i used gnet and gobwas/ws together. Https://github.com/clubpay/ronykit
The related code is in std/gateways/fastws
@ehsannm Thank you! This is really helpful.
Have you tried sending a websocket message that is larger than the ReadBufferCap
set in gnet though? I think your implementation definitely resolves the first issue for me, since the part of reading all the control frames is in a loop.
But once you get a text/binary payload frame, if the frame size is bigger than the ReadBufferCap
set on gnet, I believe, you would also run into the short-buffer error (or you might incorrectly miss a few bytes of the message, which will be read in the next OnTraffic
which can corrupt all interactions after that point for that connection ).
For example, if you set ReadBufferCap
to 1024, the websocket message can only be upto 1016 bytes (the remaining 8 bytes are used for the frame header)
@spy16 thanks for the point, i did write a test in the testenv
package and realized that you were right about the issue, i fixed it and pushed. You can check it again.
Thanks, I will check this out.
I will also close this issue since it's more related to the source reader itself than this package.
I am trying to use
gobwas/ws
withhttps://github.com/panjf2000/gnet
library in an attempt to build a high-performance websocket server.I am running into
io.ErrShortBuffer
error under two cases:I don't have deep understanding of the websocket protocol internals, but I believe this happens due to the continuation & fragmented frames? I found this reference but it's bit unclear ..
Are there any other examples to use
gobwas/ws
to use with a model likegnet
? I believe, what I need here is to use a buffered reader in between instead of directly passing thegnet.Conn
to thewsutil
/ws
functions.