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 to System.out. 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?
After many many testing, I found that if I use "myConn.getInputStream().read()" I have 100% chances hitting the problem. If I use "myConn.getInputStream().read(byteArray, offset, length)" the chance reduced to 10%. 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?
I am having a similar issue I think. When I try to write to an output stream, I get a socket reset error, but only when connected to my companys network. When I run this same code outside my companys network, everything executes as expected. Was it a firewall issue ? Did you ever resolve this ?
Joined: Dec 05, 2011
So far I can only resolve part of the problem. If you think it is a firewall issue, talk to the network admin of your company. Some company has proxy server and you need to know the server name and port no. to get through. I further tested my problem and have some progress. See if it help.
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 simply wait and wait without abort or exception. Here is a summary of my test:
With higher chance (but not always) of success:
1. use read(byteArray, offset, length)
2. write the byteArray to outputStream immediately
3. small inputStream size (e.g web page small)
4. 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. go through any (not just the byteArray in read) array, even a simple loop
3. large inputStream size
4. 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.