'How can i setup connection timeout error in websocket?

I am trying to toast a message if I don't get a response from a WebSocket connection but I am not able to figure out how to do so



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source