Open nncsang opened 1 year ago
No, it's not thread safe.
@cristaloleg is there any function supporting writing message to a connection concurrently?
Just access it with sync.Mutex
and voila. You can share a small code snippet, so it will be easier to suggest what/where to change.
@cristaloleg How about ws package?
What exactly?
@cristaloleg is ws write methods thread safe?
Sorry, missed your response. Depends on the param, functions themself are thread-safe, params might not be.
hi @cristaloleg , is it thread-safe between wsutil.WriteServerMessage()
and wsutil.ReadClientText()
?
I guess wsutil.ReadClientText()
writes pong message sometimes.
These are just funcs, they depend only on the given params. If a passed io.ReadWriter
is not thread-safe you might get a data race.
I guess wsutil.ReadClientText() writes pong message sometimes.
I don't see any write-specific call in it. Can you clarify why you think it writes pong messages?
I have experienced the "Invalid frame header" and "One or more reserved bits are on: reserved1 = 0, reserved2 = 1, reserved3 = 0" when calling WriteServerMessage concurrently from multiple goroutines.