mokyu
When the destination server is down, WebSocketStream stops and the program crashes.
I'm running the following code:
When the localhost server is down, the code crashes and stops. With a normal WebSocket, it continues to run without stopping. How can I make it run continuously without stopping?
2 replies
Can someone explain WebSocketStream to me?
Whenever I try to connect using WebSocketStream and the host doesn't respond, my program inevitably crashes and stops. I'd like to have the program attempt to reconnect without stopping even if an error occurs, but I can't seem to make it work. Does anyone have a solution for this?
function webSocketStream_Connection() {
try {
const wss = new WebSocketStream("wss://localhost")
} catch (err) {
setTimeout(() => webSocketStream_Connection(), 5)
}
}
webSocketStream_Connection()
error: Uncaught (in promise) ConnectionRefused: 対象のコンピューターによって拒否されたため、接続できませんでした。 (os error 10061)4 replies