Note that there are some explanatory texts on larger screens.

plurals
  1. POThread keeps hanging on Socket / Printwriter interaction
    text
    copied!<p>My program runs for a while (about 20 seconds) after that it sends fewer and fewer messages until it stops. I've made a Thread dump and it points me to the following line of code where the thread stops:</p> <pre><code>if(s.isClosed() || !s.isConnected() || s.isInputShutdown() || s.isOutputShutdown() || out == null || out.checkError()) { </code></pre> <p>This is a part of my thread dump</p> <pre><code> "class xxx.xxx.xxx" prio=10 tid=0x000000000200d800 nid=0x6e7f waiting for monitor entry [0x00007f63172b6000] java.lang.Thread.State: BLOCKED (on object monitor) at java.io.PrintWriter.flush(PrintWriter.java:291) - waiting to lock &lt;0x00000000ec810218&gt; (a java.io.BufferedWriter) at java.io.PrintWriter.checkError(PrintWriter.java:330) </code></pre> <p>This thread dump info points out that the problem lies in Printwriter.checkError(). But i can't understand why it would stop here.</p> <p>Below is the code in it's context. (receivers is a <code>Map&lt;Socket, PrintWriter&gt;</code>)</p> <pre><code>public void parseMessage(final byte[] bytes) { synchronized (receivers) { for (final Socket s : receivers.keySet()) { final PrintWriter out = receivers.get(s); if(s.isClosed() || !s.isConnected() || s.isInputShutdown() || s.isOutputShutdown() || out == null || out.checkError()) { receivers.remove(s); failedToConnect(s.getInetAddress().getHostAddress(), s.getPort()); continue; } queue.add(out, bytes); } } } </code></pre> <p><strong>Update 14 januari (10:00 GMT+1):</strong></p> <p>Replaced the <code>PrintWriter</code> with a <code>BufferedWriter</code></p> <p><strong>Update 14 januari (16:00 GMT+1):</strong></p> <p>I've runned some more tests and it turned out that some kind of communication problems between some network/readers is causing troubles. The application is sending data to some readers in it's internal network en to some readers in some outside networks (through internet). What exactly causes this is still unknown a this point but there are some clues. After a few restarts i could see that connections between two networks where not closed so the connections stayed open. I still don't know what is exactly happening here but it looks to me it's some kind of network issue. On de server side the connections stays in "FIN_WAIT1" and on the reader side it stays "ESTABLISHED". It looks like the reader won't signal to close the connection even a signal has been send to close it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload