Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SocketException: Connection reset , using HttpURLConnection

807606Apr 9 2007 — edited Apr 9 2007
hello everybody, i'm using this to read a xml from internet:
       URL url;
            HttpURLConnection urlcon;
            url = new URL (urlString);
            System.out.print("Connecting ....\t");
            urlcon = (HttpURLConnection)url.openConnection();
            if(!urlcon.getResponseMessage().equals("OK"))
                return -1;
            System.out.println("Done!");
it gives me:

java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unkno
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at java.net.HttpURLConnection.getResponseMessage(Unknown Source)

when i do urlcon.getResponseMessage()....

Any ideas why this happens?

PS: when i try the same URL in a browser, it opens the file fine .....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2007
Added on Apr 9 2007
10 comments
5,951 views