This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.net.SocketException: Connection reset

 
Mukesh Rawat
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is this:

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
class ResponseCodeCheck
{

public static void main (String args[])
{
try{
URL url = new URL("http://easywayserver.com/");

HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("HEAD");
connection.connect();
System.out.println("Response code of the object is "+ connection.getResponseCode());
}catch(Exception e){
e.printStackTrace();
}
}
}




it gives the error:-
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
at ResponseCodeCheck.main(ResponseCodeCheck.java:17)


Anyone tell me why this happenning.


Thanks,
Mukesh
 
Chris Janicki
Greenhorn
Posts: 21
Mac OS X Netbeans IDE Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not too familiar with the HEAD request, but it looks like the web server is simply closing your socket, probably because it's not happy with your interaction. I found this example of a HEAD interaction… Notice that the client is sending more info than you are. My guess is that your target server times out waiting for that additional info.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic