'NetSocket write exception when network becomes unreachable
I am using NetSocket class to write data to a TCP server. When the TCP server gracefully shuts down, socket's close handler is invoked and everything is working correctly. However, when I cut off the network during execution, I get success on write handler. In pure Java I would get something like this java.net.SocketException: Broken pipe.
Is this a bug and how to implement this? I would like to avoid implementing my own timeout and rather have the info when the socket is abruptly closed.
This is the code I'm using for writing:
socket.write(requestCommandBuffer, writeBuffer -> {
if (writeBuffer.succeeded()) {
//I always get success here, even when other side abruptly closes the socket
LOG.info("Successful write.");
} else {
LOG.error("Failed to write.");
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
