Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting a connection hangs after many socket reads  RSS feed

 
olze oli
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i wrote a little application which retrieves some websites.
the application is working fine for about 1h and then it just hangs.
i cant see whats wrong - the only thing i found out is that it hangs on the socket read calls:

one thread (in netbeans) which i suspended hangs at this:
SocketInputStream.socketRead0
SocketInputStream.read:129
...

I use apache's httpclient library and also the URL class from java (if the download is simple)
the URL class produces the following thread:
SocketInputStream.socketRead0
SocketInputStream.read:129
BufferedInputStream.fill:218
BufferedInputStream.read1:258
BufferedInputStream.read:317

i have no idea whats going wrong... any help is appreciated

 
olze oli
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just noticed that many connections which should be closed are in a WAIT_CLOSE state
i'm now calling gc every 5 seconds and it looks like its working
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
olze oli wrote:i just noticed that many connections which should be closed are in a WAIT_CLOSE state


The OS does that to make sure it doesn't reuse a closed port that is in an indeterminate state. I don't think calling gc would make a difference.
Honestly, without more details, we are just guessing.
 
olze oli
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what informations do you need?
i think its just the same bug as in http://www.velocityreviews.com/forums/t143676-hanging-up-in-tcp-close_wait-state.html and/or http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6215050
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
olze oli wrote:what informations do you need?


Have you read our FAQ, HowToAskQuestionsOnJavaRanch?



The bug you link to is closed and fixed for JDK 1.5:
A number of developers on the JDC have posted comments suggesting that his bug is not fixed in 5.0 update 7 on Linux. . . Most likely this application creates a new thread everytime when need to "poll and process" the request and then throws away the thread later. Yes, such a use scenario will cause a temporary fd "leakage", before a GC kicks in.


Does this sound like what you are doing?
 
olze oli
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what informations do you need?

why dont you simply answer that question? do you need code? i cannot give you any code because this is not a opensource project where i simply can paste as much code as i'd like to.
all other mentioned points in that faq are fulfilled, i think. otherwise please tell me which point you exactly mean.

The bug you link to is closed and fixed for JDK 1.5:

which means nothing, few months ago i found a bug which should have been fixed in 1.4 which still occured in 1.6.22

Most likely this application creates a new thread everytime when need to "poll and process" the request and then throws away the thread later.

yes, its a webcrawler which uses many threads. each thread connects to a server, download the information i want and close the stream. it should close the stream as i call it explicit, but it simply hangs. mostly at about 600mb - now i got 2.6gb and its still running fine, no WAIT_CLOSE states so i'm pretty sure it is a bug
i will check it in a couple of hour if my tool is still running fine
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!