Closed gzw13999 closed 1 week ago
Got it, it turns out concurrency is not supported
The documentation describes the allowed concurrency. Concurrent writes are not allowed.
A quick fix is to protect write to the connection with a mutex.
Thank you, got it
A thing that i have done many times is to wrap the Websocket connection in a struct, together with a Mutex in a custom struct and making a few methods 'public'. Therefore, you have a 'LockedConn' struct which hides the lock completely.
This issue should be closed. The application writes to the connection concurrently.
Is there an existing issue for this?
Current Behavior
I used about 10 goroutines to execute the conn.WriteJSON method concurrently, and the following panic occurred:
Can't conn.WriteJSON be executed concurrently?
Expected Behavior
There should not be a panic that causes the program to terminate.
Steps To Reproduce
The access is to a third-party API and no recurrence pattern has been found yet.
Anything else?
No response