Skip to main content

socket reset

Please note these forums are being decommissioned and use the new and improved forums at
3 replies [Last post]
Joined: 2008-09-24

I use NetBeans both at work and at home, v7.0.1. Recently, I developed a small program to read web page and list out the html code. Simple HttpURLConnection coding, with own coding (byte-by-byte reading) to parse. It works fine in my office, but not at home! In the office, the whole html code is listed. At home, it stopped in the middle with socket reset. Trace debugged the coding, tested with different web site, but all ended up stopping after reading about 10K to 16K bytes. Web page smaller than this works fine even at home. I am just wondering whether it is possible that my ISP has policy limiting web access with self-coded web client. Anybody encountered similar problem with their ISP?

One point to note: in the office I use jre6, at home it is jre7. Is this related to my problem?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-24

I have had different issues in the past with ISPs and content. What happens if you retry the connection? Too, have you download Java 6 and installed it to try it out? What about trying 7 at work? You can easily tell if there is some weird difference.

Joined: 2008-09-24

Thanks for the reply. Have tried j6 at home and j7 at office, but still the same, at home not working while at office runs fine. After further testing with difference way of reading the web site, I found that if I use "myConn.getInputStream().read()" I'll have this problem. If I use "myConn.getInputStream().read(byteArray, offset, length)" I don't have this problem. Again either way works in the office, but only the later works at home. Anybody has any ideas whether this related to java setting or windows setting or network settiing?

Joined: 2008-09-24

I further tested my problem and have some progress. The read(byteArray, offset, length) is not always work. I found that if I simply read it this way, or the page is small, it has no problem. But if I do some processing (e.g. go through the array for data) or the page is large, my program will either socket reset or simply wait and wait without abort or exception. Here is a summary of my result:

With higher chance (but not always) of success:
1. use read(byteArray, offset, length)

2. user byteArray size same as inputstream length
3. write the byteArray to outputStream immediately
4. small inputStream size (e.g web page small)
5. run it in simple java command line (at least stopped at later part of the stream)

With lower chance (almost always) of success:
1. use read()

2. use smaller byteArray
3. go through any (not just the byteArray in read) array, even a simple loop
4. large inputStream size
5. run it inside a servlet container (stopped at earlier part of the stream)

Again this only failed at home but same codes work in my office. Anybody has any idea what's wrong.