From my testing between TCP client and TCP server using node tls package, there is no any defined timeout. Basically as it seems one side could wait for hours for answer without any error or timeout event occur.
What one can do is something like following:
socket.setTimeout(10000)
socket.on('timeout', () => {
console.log('timeout occur')
})
Still nothing would happen from connection perspective, everything is running as normal, so if one wants to force reconnect/disconnect, could do something like:
socket.setTimeout(10000)
socket.on('timeout', () => {
console.log('timeout occur')
socket.end()
socket.destroy()
})
And good enough, but this timeout will fire only if both sides TCP client and TCP server are not sending anything. Is there any way to define something like read-timeout which will be emitted when TCP server is not responding in defined amount of time, like 10 seconds or whatever?
via Srle
No comments:
Post a Comment