Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What Does "Connection reset" Message Mean and How Can I Prevent It?

 
Kevin Simonson
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a couple of very simple Java programs, "SeBug.java" that takes three arguments, and "ReBug.java" that takes two. The first argument for "SeBug.java" is the port of the socket to use for communication between the two programs, and so is the first argument for "ReBug.java". The second argument for "SeBug.java" is a base to be raised to different powers, and the third argument is the number of powers to be raised to. The second argument for "ReBug.java" is the IP address of the machine I'm executing "SeBug.java" on. The actual code of "SeBug.java" is:

and the actual code of "ReBug.java" is:

When I run "java SeBug 13267 2 5" on machine "10.35.4.226" and then run "java ReBug 13267 10.35.4.226" several times in succession on a different machine, the result I get on the second machine is:

Script started on Thu 26 Jan 2012 06:53:18 PM GMT
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
Read power 1.
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
<IOException> thrown with message "Connection reset".
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
Read power 2.
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
Read power 4.
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
<IOException> thrown with message "Connection reset".
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
Read power 8.
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
<IOException> thrown with message "Connection reset".
simonsonkm@nncd-077-049 cds-dev:~/Java$ java ReBug 13267 10.35.4.226
Read power 16.
simonsonkm@nncd-077-049 cds-dev:~/Java$ exit
exit

Script done on Thu 26 Jan 2012 06:53:51 PM GMT

Does anybody know what the message "Connection reset" means when <IOException> is thrown the second, fifth, and seventh time I execute program <ReBug>? And what can I do to read the data without this exception getting thrown?

Kevin Simonson
 
Henry Wong
author
Marshal
Pie
Posts: 21114
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin Simonson wrote:Does anybody know what the message "Connection reset" means when <IOException> is thrown the second, fifth, and seventh time I execute program <ReBug>? And what can I do to read the data without this exception getting thrown?


A "connection reset" means that the network connection was close improperly, by the other side. It could be that the other application died. It could be that the network switch/router failed. etc.

Regardless, you can't do anything about the connection reset, at the application that got the reset exception -- as it is an error that occurs elsewhere. To fix this problem, you need to fix it where it occurs.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic