robtaussig / react-use-websocket

React Hook for WebSocket communication
MIT License
1.63k stars 135 forks source link

How to manually close and reconnect a socket? #56

Closed Astra-RX closed 4 years ago

Astra-RX commented 4 years ago

In my situation, I need to temporarily close the connection and reconnect on the user's action. But native close() is protected and I don't find a method to reconnect a closed connection except for the built-in auto reconnecting.

hoanglam10499 commented 4 years ago

@Artoria-0x04 Untitled Untitled

eric-blue commented 4 years ago

close?

robtaussig commented 4 years ago

Thank you @hoanglam10499. Closed.

Astra-RX commented 4 years ago

Thanks, I haven't noticed that and temporarily reject the async getSocketUrl instead.