Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Network dropped connection on reset [duplicate]

I've written a multi-threaded UDP Proxy in Java using DatagramChannels.

It works fine until the following exception appears:

java.net.SocketException: Network dropped connection on reset: no further information 
at sun.nio.ch.DatagramChannelImpl.receive0(Native Method) 
at sun.nio.ch.DatagramChannelImpl.receiveIntoNativeBuffer(Unknown Source) 
at sun.nio.ch.DatagramChannelImpl.receive(Unknown Source) 
at sun.nio.ch.DatagramChannelImpl.receive(Unknown Source) 
at com.fabio.rotumaster.proxy.ProxyMain.handlePacket(ProxyMain.java:189) 
at com.fabio.rotumaster.proxy.ProxyMain.run(ProxyMain.java:169) 
at java.lang.Thread.run(Unknown Source) 

In ProxyMain.java on line 189 there is only the receive method being called:

SocketAddress sender = this.clientChannel.receive(buffer);

The error appears randomly from time to time. Sometimes only once and sometimes 5 of them in a row.

Does anyone have an idea?

like image 399
modsfabio Avatar asked Oct 21 '25 16:10

modsfabio


1 Answers

This is Winsock error 10052: WSAENETRESET:

Network dropped connection on reset.

The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress. It can also be returned by setsockopt if an attempt is made to set SO_KEEPALIVE on a connection that has already failed.

How you can possibly get that on a UDP socket appears to be a mystery, but MSDN also says under recvfrom():

For a datagram socket, this error indicates that the time to live has expired.

And @David Schwartz says:

This is one of many errors that UDP implementations tend to uselessly report to applications. You pretty much have to ignore them all.

like image 68
user207421 Avatar answered Oct 23 '25 04:10

user207421



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!