gkaindia.com

Home > > Call to flush() does not return

Call to flush() does not return

Advertisement
I have an application that manages network connections to various other applications and sends and receives messages (lines of text) to and from each. Each message to be sent is written to the socket's output stream, followed by a call to flush()
Occasionally, a call to flush() on one of the sockets will freeze, and fail to return. This behavior is random and fairly rare and thus I haven't been able to reproduce it. A stack trace of the affected thread follows:
TradeThread 2" daemon prio=10 tid=0x0000000043618800 nid=0x4b5 runnable [0x00000000427f4000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
        at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
        at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
        at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
        - locked <0x00002aaab36a6558> (a java.io.OutputStreamWriter)
        at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
{code}
Perhaps the buffer on the consumer end of the socket is full, but that seems unlikely, as the app consuming the messages has no exceptions, and seems to be performing fine (i.e. is not consuming messages slower than they are being sent).
Does anybody know of any other reason a call to flush would not return?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
Advertisement
Will that call block forever?No, see below. However there's no write timeout if that's what you mean.
It seems that being unable to flush a buffer because the consumer won't take any more data would warrant an exception being thrown.Why? What if the consumer stops reading for an hour? a day? a year? Where exactly are you going to draw the line? A write timeout would be nice but TCP doesn't have one.
What if the app on the consumer side of the connection exits? Wouldn't that cause an IOException to be thrown?Yes, IOException: connection reset by peer, if the peer closes the connection via any means.
Read the other 5 answers
Hey, I am working with BlazeDS and JBoss 5. In Jboss I have AuthentificationFilter  before  Remote Objects... So each request must pass throw this filter. On server side: In the filter I am checking login session data and if it is ok ,it passes to Re
hi everbody Graphics.drawString is not working properly on Linux , how can i fix it. what is problem. on XP , 10gR2 db evertything is ok. 326x160 picture and "Sample Text." seen on browser. on Oracle Unbrakeble Linux , 11g db 326x160 picture see
hi, i tried to write a java program to which will take username and password and login to a given site. but some how its not working. i am actually trying to login to the follwoing website: https://roundup.ffmpeg.org/roundup/ffmpeg/ can anyone provid
I have an applet that serializes a transport bean to a servlet on tomcat, the servlet makes a PDF that I want to display on the browser. I had thought that if I simply set the MIME type and return the binary data, the browser would know what to do. B
Hi For this assignment i create a databse with Acces. when i run the following code i get an error message. Dropping indexes & tables ? Could not drop primary key on UserStocks table: [Microsoft][ODBC Microsoft Access Driver] Cannot find table or con
          Hello,           We have developed a client that connects to servlets in WebLogic 4.5.1. Some of the servlets use sessions to store data, and they receive some parameters from the client to retrieve information from a database.           Wh
I have a URL from a jsp page which points to a struts action servlet. This works with firefox via http and https. With IE it works via http but it doesn't work via https. The error message I get is "Internet Explorer cannot download ...File_name.doc
Hi Everyone, I have a problem while compressing the unicode file name in a zip file. I used the below code for compressing the unicode files. String[] source = null; // C:\\TestData\\unicode_filename.txt :  unicode_filename.txt is the file created in
I am having servlet for downlading a file from server. When I call this servelt I am able to get the file from server but I get a save dialog box which I do not want. I want that this file should be stored at a specific location given by me in a serv
Hi friends, I have the code of a simple File Based Multithreaded Web Server. I have been asked to add proper http/1.1 Keep-Alive behavior to it. As far as I understand it means to use the same socket for the request coming from the same client withou
Was given a stock tracking application to be edited for use as a Student/Admin login application which accesses a database and adds/deletes/edits student information. When I try to login, I get the following error: [Microsoft][OBDC Microsoft Access D
Hi all, I have a imag tag in jsp on click on the image i am submitting the form 1. i have used the below code HSSFWorkbook wb=viewHelper.getExcel(); response.reset(); ServletOutputStream outs = response.getOutputStream();      response.setContentType
Hi, I am trying to stream out a binary file to an output stream (not a file, but a socket). My file is a gzip file, and I was initially simply trying to open the file, read it to a a byte array, and writing it out to my output stream. However, I got
Hi people, I'm in urgent need of help for a project I'm working on for my degree. Background: I am writing a package that will allow connectivity to a c++ server via streaming sockets. The c++ server sends/receives data as unsigned bytes. This is my
Hi, I can't get special characters like á é í, etc well-printed in an jsp page when processing an ajax request under struts. The oracle database is encoded with ISO-8859-1. In my action i set the character encoding for the respose: PrintWriter out =
I have the following which sends a print file to a specific printer. It works perfectly in Windows 7, but not in Windows 8. The print job shows in the print queue until the print job is closed. Then the print job literally vanishes from the print que
Pardon the cross-posting (Java Servlet Technology), but when I was researching this problem I found alot of people asking this question in here as well as in the servlet forum. So I thought this code would be helpful here too. Here is a complete work
I use JAXP 1.1 to read a xml file as a DOM tree. I can make change to the DOM tree in the memory, such as add an element or change the node value, but how can I apply these changes to the source xml file, i.e., write the changes back to the disk?you
Hi All, Im tryin to design a website to take an image out of the database and display it on the jsp page. I call the image using: <img src="ImageServlet?id=3" width="250" height="250" align="top"> This calls t