Closed AnirudhDensityIntern closed 3 months ago
I want to make new connection and insure the previous websocket Should be closed, when I renew the older websocket thats why I need to check the webscocket is closed or not.
If you are not exporting isClosed Variable can you please make a function that exports the boolean value for the websocket
I think your way is not correct, that's useless to export isClosed coz:
That's why I said you don't need to check it's state.
I know when we call conn.close it closes the stream but in order to renew the websocket I will again do conn.close on the closed channel but in that case i will get error, So I need to ensure the websocket is closed or not before closing the channel also I dont want to make 2 same stream at any moment.
You don't need to re-create it when it's healthy! You should re-create a new conn when OnClose.
Why do you want to re-create it when it's healthy? Even you want to re-create a new conn when the old one is still healthy, you just need to close the old one and create the new one, you don't need to care about whether it returns err when you close the old one!
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
For opening:
or register open handler by
upgrader.OnOpen
For closing:
register close handler by
upgrader.OnClose
You don't need to check the state of the ws conn when you use it everytime.