-
Notifications
You must be signed in to change notification settings - Fork 301
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
Add protection against concurrent Readers #391
Comments
I'm getting something slightly similar using the same version: |
Me too- I've checked with wireshark and the websocket frame is OK, it's just being parsed wrong on nhooyr/websocket's side. |
That's quite concerning that all three of you guys are seeing that... I'd suggest disabling compression though it'll be disabled by default in the next release. I'll go through the code again to see if I can find the bug. The autobahn compression tests pass fine under the race detector so I'm surprised to see a bug like this. |
@soypat If possible, can you share the frames you checked with wireshark? Maybe I can replay them with the library and thus reproduce. That would help immensely in debugging. |
There's been enough changes for v1.8.8 that whatever this was is likely fixed. Compression in particular is disabled by default now and I recommend keeping it that way. Let me know if you see it again once v1.8.8 is released. |
Nvm I was able to reproduce, see 249edb2 |
Were you guys using the library through a proxy? |
Nvm, that bug was from my proxy not working correctly. Fixed now. |
Actually nvm, this is probably caused by #355 so I'll close after fixing that. |
Done so closing. |
I still see this error on occasions. Seen it today on the latest release: Whenever I see it, it so far has always been the result of me having two readers open at the same time. It states in the library that Not sure if the error message could be clearer for diagnosis. Adding this quick comment here in case anyone comes across this issue and finds this thread. |
Ah yea that would do it. I'll add a link to this thread in that error message. Could also add some protection here perhaps without much performance cost. |
I wonder if there is also a way to have two readers, where both (or multiple) receive the same message. This would be helpful for me in a number of scenarios. Or maybe when initiating one reader it closes the other. I am already passing the ws connection around, but ideally wouldn't have to pass around the reader, and could just close one and open it up elsewhere. |
There shouldn't be any scenario where you want to do a concurrent read on the connection. There should only ever be one goroutine reading from the connection. Can you clarify why you feel you need multiple readers or even why you're passing the reader around like that? Perhaps an example in code? |
On the multiple reader, makes sense. Closing and reopening or passing around, I read in a loop but some messages call a series of functions and those functions need to take over the connection and receive all future messages after their call. For those functions I need to either stop the loop and move the reader down or relay all messages through a channel on through another connection. Hard to fully explain, maybe at some point it will hit me how best to do it. Didn’t want to hijack the thread though, will think on it. |
The problem still appear in my project? |
Hello, I also have similar problem in my project. in my log, "readPacket() s.conn.ReadMessage() err: failed to get reader: received header with unexpected rsv bits set: true:false:true" It could be helpful if I leave code snippet?
|
@jazzcake-diverse I don't see anything wrong in your snippet, but there could be issues in the surrounding code. Have you made sure it's not possible |
@mafredri Thank you for feedback. The code snippet is part of goroutine, readPacket() which is run for each session(websocket.Conn from Accept). So I don't think it can be called simultaneously from other goroutine. In client side, I use 3 websocket, 1) UnrealEngine 5 websocket plugin, 2) Godot 4 Websocket, 3) this library as client. This error usually appear in Unreal and Godot side.
|
During my use of the library(server and client both v1.8.7), the server occasionally receives the following prompt,
which seems to be related to this part of the code.
write.go L300:
Could you please confirm if it is necessary to add the following code here?
The text was updated successfully, but these errors were encountered: