<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: SSL bisocket socketWrite0() hangs, while holding Messaging Post Office lock (on a network failure)
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/toddler">Todd Sandor</a> in <i>JBoss Remoting</i> - <a href="https://community.jboss.org/message/799630#799630">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I found a workaround to this SSL defect which is to set the socket linger option in OutputTimerTask.run()</p><p>before the close() is performed. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've never contributed to the community source, but below are the</p><p>diffs, hopefully someone can get this into the community version to tell me how I go about contributing</p><p>this change into the community version.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>File to change: (e.g. for tag 2.5.4.SP3)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>org.jboss.remoting.transport.socket.ClientSocketWrapper.java</p><p>org.jboss.remoting.transport.socket.TimedOutputStream.java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>diff ClientSocketWrapper.java ../ClientSocketWrapper.java </p><p>223c223,224</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; os = new TimedOutputStream(os, writeTimeout);</p><p>---</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Socket mySkt = super.getSocket();</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; os = new TimedOutputStream(os, writeTimeout, mySkt);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>diff TimedOutputStream.java ../TimedOutputStream.java </p><p>26a27</p><p>&gt; import java.net.Socket;</p><p>47a49,60</p><p>&gt;&#160;&#160;&#160; private Socket mySkt;</p><p>&gt; </p><p>&gt;&#160;&#160;&#160;&#160; public Socket getMySkt() {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return mySkt;</p><p>&gt;&#160;&#160;&#160;&#160; }</p><p>&gt; </p><p>&gt;&#160;&#160;&#160;&#160; public TimedOutputStream(OutputStream os, int outputTimeout, Socket pmySkt)</p><p>&gt;&#160;&#160;&#160;&#160; {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.os = os;</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.outputTimeout = outputTimeout;</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.mySkt = pmySkt;</p><p>&gt;&#160;&#160;&#160;&#160; }</p><p>134c147</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>---</p><p>&gt; </p><p>142,151c155,192</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.debug(this + " closing: " + tos);</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tos.close();</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tos = null;</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch (IOException e)</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.debug("unable to close " + tos);</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>---</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&gt; </p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Socket mySocket = tos.getMySkt();</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (mySocket != null)</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // set the linger on with duration 0, results RST being sent</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // and socket send and receive buffers being discarded (does not</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // wait of the existing write() to complete].&#160; There is no use in</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // setting the soLingerDuration longer then 0 (thus waiting for the write to</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // complete), since we've already waited "writeTimeout" seconds on this write.</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; boolean on = true;</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int soLingerDuration = 0;</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.debug(this + " socketWrite TIMEOUT: set soLinger(ON,0): " + tos);</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mySocket.setSoLinger(on, soLingerDuration);</p><p>&gt; </p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch (IOException e)</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.debug(" socketWrite TIMEOUT: Attempting to set linger on socket stream [" + tos +</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; "], Exception [" + e.toString() + "]");</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; finally</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.debug(this + " socketWrite TIMEOUT: close(): " + tos);</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tos.close();</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch (Exception e)</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // ignore - log log error</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.error("Failed to close() socket stream Exception: ", e);</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.debug(this + " socketWrite TIMEOUT: close() completed.");</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tos = null;</p><p>&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>153c194</p><p>&lt;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>---</p><p>&gt; </p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/799630#799630">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Remoting at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2050">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>