java.net.SocketException: Connection reset by peer: JVM_recv in socket input
stream read
at java.net.SocketInputStream.socketRead(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:86)
at java.net.SocketInputStream.read(SocketInputStream.java:67)
at java.io.InputStreamReader.fill(InputStreamReader.java:173)
at java.io.InputStreamReader.read(InputStreamReader.java:249)
at java.io.BufferedReader.fill(BufferedReader.java:139)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
"Karen" <looking...@hotmail.com> wrote in message
news:a80s6h$pvf$2...@newsg4.svr.pol.co.uk...
Matt
"Karen" <looking...@hotmail.com> wrote in message
news:a80s6h$pvf$2...@newsg4.svr.pol.co.uk...
"Peter Wu" <no.j...@il.net> wrote in message
news:a812q5$ov4g7$1...@ID-117651.news.dfncis.de...
"Matthew F. Dennis" <ma...@merfer.net> wrote in message
news:a81mah$dmr$1...@news.cs.utexas.edu...
BufferedReader in = getInputStream();
StringBuffer buff = new StringBuffer(1024*20);
String s;
while((s=in.readLine())!=null) {
buff.append(s);
buff.append(CRLF);
}
The get the connection reset problem occuring. The program is terminiated
at the while ((s=readLine.... line and the next reference is to the
BufferedReader :
public String readLine() throws IOException {
return readLine(false);
}
See my previous post (below) for the thread of errors. Im thinking maybe if
I use a try and catch I can resend the request, can i do this?
Thanks,
K.
x
"Matthew F. Dennis" <ma...@merfer.net> wrote in message
news:a81mah$dmr$1...@news.cs.utexas.edu...
>So it is definitely the host that is closing the connection and not me, the
>client somehow?
yep
> Is it possible to catch this exception and resend my
>request so that if this happens, I can retry the request? What ive done is
>opened a socket, and got an input stream, then I read each line of the
>stream, and appned it to a string buffer.
>
> BufferedReader in = getInputStream();
> StringBuffer buff = new StringBuffer(1024*20);
> String s;
>
> while((s=in.readLine())!=null) {
> buff.append(s);
> buff.append(CRLF);
> }
>
>The get the connection reset problem occuring. The program is terminiated
>at the while ((s=readLine.... line and the next reference is to the
>BufferedReader :
> public String readLine() throws IOException {
> return readLine(false);
> }
>See my previous post (below) for the thread of errors. Im thinking maybe if
>I use a try and catch I can resend the request, can i do this?
yes, catch the SocketException - but it would be a good idea to not get caught
in an infinite number of retries, so you'd want to set a limit.
You can demonstrate the behavior for yourself, by using a simple server
program (with ServerSocket and Socket) and a simple client program (with
Socket). Start each from a separate dos window. Once the connection is
established, close out one side or the other with ctrl-C and observe the
exception in the other side.
>
>Thanks,
>
>K.
>x
>
>"Matthew F. Dennis" <ma...@merfer.net> wrote in message
>news:a81mah$dmr$1...@news.cs.utexas.edu...
>> It means the connection was closed/reset by the other host. It is similar
>> to trying to read from a file that is closed.
>>
>> Matt
>>
>> "Karen" <looking...@hotmail.com> wrote in message
>> news:a80s6h$pvf$2...@newsg4.svr.pol.co.uk...
>> > What does all this mean? It keeps on coming up at various times as I am
>> > connecting to a server and retrieving their pages.
>> >
>> >
>> >
>> > java.net.SocketException: Connection reset by peer: JVM_recv in socket
>> input
>> > stream read
>> >
>> > at java.net.SocketInputStream.socketRead(Native Method)
>> >
>> > at java.net.SocketInputStream.read(SocketInputStream.java:86)
>> >
>> > at java.net.SocketInputStream.read(SocketInputStream.java:67)
>> >
>> > at java.io.InputStreamReader.fill(InputStreamReader.java:173)
>> >
>> > at java.io.InputStreamReader.read(InputStreamReader.java:249)
>> >
>> > at java.io.BufferedReader.fill(BufferedReader.java:139)
>> >
>> > at java.io.BufferedReader.readLine(BufferedReader.java:299)
>> >
>> > at java.io.BufferedReader.readLine(BufferedReader.java:362)
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>
--
Regards,
Ken Kalish
there is no Java cartel
When I catch the exception, how do I resend the request? I have caught the
exception and resend the request by sending my get headers again, but the
socket doesnt respond and I dont read anything from the read reseponse
stream.... if (buff.length()==0) and enters this loop instead of entering
the readLine stream. I think maybe I have to wait a while and then resend
the request when the host is ready, but how can I program this in?
Thanks.
K
x.
Karen wrote:
>
>
> When I catch the exception, how do I resend the request?
Make a new connection (a new Socket). The old one is dead and useless.
EJP