aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes java.net.SocketException: Connection reset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.net.SocketException: Connection reset" Watch "java.net.SocketException: Connection reset" New topic
Author

java.net.SocketException: Connection reset

Mukesh Rawat
Greenhorn

Joined: Apr 18, 2012
Posts: 1
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

Joined: Aug 30, 2006
Posts: 21

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.
 
wood burning stoves
 
subject: java.net.SocketException: Connection reset