-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wsutil.readData() blocks until desired opcode/frame is received #85
Comments
Hi @kenfoo, This is intended behaviour of this method – that is, the word "Data" means exactly what you have discovered – read the data message, not the control. When using epoll somehow |
@kenfoo you could use
Another way could be exposing
Would be helpful to check implementation of |
@oguzhane We were experimenting along similar lines and stumbled upon this thread. |
@knadh I have ended up going for the approach reading data from the file descripter by using syscall.RawConn. However, i have not tested it under high load of traffic yet. |
@oguzhane we tried reading directly from the file descriptor and under high loads, it ran into the same issues with malformed / partial messages. |
Hi. If it is of any help to anyway, we ended up simply reimplementing what wsutil.readData did, but modified it such that it doesn't block or loop, and instead returns the bytes, the opcode and error in all cases. |
@kenfoo we attempted this unsuccessfully. It'd be nice if you could share your solution! |
In wsutil.readData(), whenever a control frame (pings) or unwanted OpCode is received, it performs a "continue" in the for loop to read the next frame (rd.NextFrame()), repeating until a wanted opcode type is received.
For most users using goroutines this is fine as it blocks until the desired data is available.
However when used with epoll this is problematic as it may potentially block. A simple solution would be to return nil,0,nil instead of performing a continue to read the next frame, but that might actually break the expected behavior of this function.
The text was updated successfully, but these errors were encountered: