I too would like to see a log extract *and* the logging code that produces it
Main Topics
Browse All TopicsGreetings...
My client connects to an HTTP server by opening a socket.
Please see below source.
BufferedOutputStream bout = new BufferedOutputStream(s.get
<<<DO SOMETHING TO READ DATA FROM bout<<>
When we disconnect HttpConnection, we do like below(exact order):
s.shutdownInput();
bout.flush();
s.shutdownOutput();
s.close();
socketClosed = true; // flag for reference/sake to future..
This is a working implementation and has been working with no worries for over 1500 end user access to application.
Recently our client has been intimated to us by providing logs, which we see while flushing "bout" or while s.shutdownOutput() it blocks for some time. It could be 20 minutes or 30 minutes which we can't predict.
I couldn't able to find it out whether it is creating blockage while doing one of below activities
1. bout.flush() or
2. s.shutdownOutput()
Please can anyone shed some more light on it? Thank you so much for your response in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks all for the replies.
Below are the logs:
2009-08-20 08:09:17,436 [SessionH] INFO: Closing output
2009-08-20 08:28:43,369 [SessionH] INFO: HttpConnection disconnected
Please note the time response. SessionH is a thread which will monitor all the sessions on our server. And will take some actions.
Please see attached code.
Any help from here, would be greatly appreciated.
I am sorry guys, bit late in delay to respond.
Thanks objects & CEHJ for helping me out. One last question.
1. I have below timeout settings configured.
s.setSoTimeout(0);
s.setSoLinger(true, 0);
s.setTcpNoDelay(true);
2. My question is on setting SoLinger(true,0). setting linger to "true" and linger time out to "0" means - stop reading & sending the data immediately. Data in sent & receive buffer will be DISCARDED. And finally socket will be closed immediately.
My doubt is - If the client is already expecting some data from the server (please note that there is no time out set) and we have closed our send & receive buffer by discarding it.
Is there any chance to hang at socket.close() statement, because client is already called socket.read()....??? Since, there is no socket timeout set, calling socket.read() will never gets terminated....
Any ideas?
> you haven't answered why you are trying to close the socket explicitly
what happens when you just close the stream?
TBF, I am not the designer of this code. Working to fix one issue. You are right, if we close the stream that should also be fine. I can keep this in my mind.
Please could you confirm my below doubt, does it make sense?
>>> My doubt is - If the client is already expecting some data from the server (please note that there is no time out set) and we have closed our send & receive buffer by discarding it.
Is there any chance to hang at socket.close() statement, because client is already called socket.read()....??? Since, there is no socket timeout set, calling socket.read() will never gets terminated....
Business Accounts
Answer for Membership
by: InteractiveMindPosted on 2009-08-28 at 04:37:40ID: 25206491
Is any other information provided by the logs? (Any chance you could share them?)
Also, how often is this happening now?
By the way, shutdownOutput() automatically flushes the output stream prior to termination, so you can get rid of the bout.flush() call. Perhaps this is leading to problem...
A temporary fix: create a custom timeout monitor - you can do this by creating a separate thread to time how long it's taking to close the connection; if the time exceeds a certain value (say, 5 seconds), then the thread will just kill the socket.