aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket "connection reset"" Watch "socket "connection reset"" New topic
Author

socket "connection reset"

terr lundamo
Greenhorn

Joined: Dec 08, 2010
Posts: 19
Hi,

i have a java program which send and recieve data from a c# program. Sometimes i get java.net.SocketException: Connection reset thrown in the java program. It seems totally random, and happends maybe 2% of the times. From the log files i can see the error is being thrown before the data "reaches" the C# listener. It looks like the data is sent and imidiately the error is thrown.

When this error occurs, the c# program still recieves the data and does it's job, but the response never make it back to the java program, and after a restart of the java program the C# program still works fine, so i believe the problem is within the java code (but that's just my opinion).

Any suggestions? i've been struggling with this for a long time..

My java code looks like this, for the socket part i mostly used an example i found online:



Thanks
Sergey Babkin
author
Ranch Hand

Joined: Apr 05, 2010
Posts: 50
The timeout may be the cause. If the receiver can't keep up, the TCP flow control causes the sending to be stopped until the reading catches up. So then the OS sending buffer fills up, and an attempt to write there would be delayed. So if it gets delayed by more than 10 seconds, probably the same timeout gets triggered. try to remove the timeout after you establish the connection. Or send the data more slowly.
terr lundamo
Greenhorn

Joined: Dec 08, 2010
Posts: 19
thanks for replying,

i'm not using the timeout, i should have removed that line..

is it possible to send the data more slowly? btw, it's not much data being sent.

Sergey Babkin
author
Ranch Hand

Joined: Apr 05, 2010
Posts: 50
terr lundamo wrote:thanks for replying,

i'm not using the timeout, i should have removed that line..

is it possible to send the data more slowly? btw, it's not much data being sent.



With not much data the timeout should not matter. But just in case, does it work any better with timeout removed?
terr lundamo
Greenhorn

Joined: Dec 08, 2010
Posts: 19
With not much data the timeout should not matter. But just in case, does it work any better with timeout removed?


actually i was never using the timeout, i just forgot to remove that lines of code. Also i should change the catch catching timeoutexception.. but i still can't figure out what's causing this, had a connection reset just hours ago, seems totally random to me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: socket "connection reset"