Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2
  • Fix Version/s: 2.0.0-M1
  • Labels:
    None
  • Environment:

    Mule 1.2, Windows 2000 SP4, and Java JDK 1.5.0_05

  • Configuration:
    Hide

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN"
    "http://www.symphonysoft.com/dtds/mule/mule-configuration.dtd">

    <mule-configuration id="MuleTCPReconnect" version="1.0">
    <connector name="tcpConnector" className="org.mule.providers.tcp.TcpConnector">
    <properties>
    <property name="tcpProtocolClassName" value="org.mule.providers.tcp.protocols.DefaultProtocol"/>

    <property name="keepSendSocketOpen" value="true"/>
    <property name="maxretryCount" value="2"/>
    </properties>
    </connector>

    <model name="muleTcpReconnect">
    <mule-descriptor name="EchoUMO" implementation="org.mule.components.simple.EchoComponent">
    <inbound-router>
    <endpoint address="stream://System.in"/>
    </inbound-router>

    <outbound-router>
    <router className="org.mule.routing.outbound.FilteringOutboundRouter">
    <endpoint address="tcp://localhost:2051" connector="tcpConnector"/>
    </router>
    </outbound-router>
    </mule-descriptor>
    </model>
    </mule-configuration>

    Show
    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN" "http://www.symphonysoft.com/dtds/mule/mule-configuration.dtd"> <mule-configuration id="MuleTCPReconnect" version="1.0"> <connector name="tcpConnector" className="org.mule.providers.tcp.TcpConnector"> <properties> <property name="tcpProtocolClassName" value="org.mule.providers.tcp.protocols.DefaultProtocol"/> <property name="keepSendSocketOpen" value="true"/> <property name="maxretryCount" value="2"/> </properties> </connector> <model name="muleTcpReconnect"> <mule-descriptor name="EchoUMO" implementation="org.mule.components.simple.EchoComponent"> <inbound-router> <endpoint address="stream://System.in"/> </inbound-router> <outbound-router> <router className="org.mule.routing.outbound.FilteringOutboundRouter"> <endpoint address="tcp://localhost:2051" connector="tcpConnector"/> </router> </outbound-router> </mule-descriptor> </model> </mule-configuration>
  • Log Output:
    Hide
    The debug output from my server test code when I ran mule and typed messages at the console was:

      +------------------------------------+
      | RAINING SOCKETS V 1.2pre0 |
      | Java 1.4 Non Blocking Framework |
      |....................................|
      | (c) Rahul Kumar, Sep 2003. |
      |....................................|
      | Status: Development-beta. |
      | Functional, tested to 10K,15K conns|
      +------------------------------------+
      
    Tue Nov 29 15:40:02 EST 2005
    Created id: 0
    Created Server Socket on:2051
    -- Started --
    Millis:1133296802782
    Tue Nov 29 15:40:02 EST 2005
    Found a channel, key:0
       -- acceptable
    Created id: 1
    =>>>>> RECV: got total:0 this total:0 cnt:0 <<== client connects to server (and immediately sends "hello")
    No data read.
    Found a channel, key:1
       -- readable 1
    =>>>>> RECV: got total:5 this total:5 cnt:-1 <<== receive "hello" and then client closes connection (cnt:-1 on read from select indicates client closed connection)

    Socket closed.
        ==>>>-- NIO h_r --:5 id:1
    hello

    Found a channel, key:0
       -- acceptable
    Created id: 2
    =>>>>> RECV: got total:0 this total:0 cnt:0 <<== client connects to server again
    No data read.
    Found a channel, key:2
       -- readable 2
    =>>>>> RECV: got total:7 this total:7 cnt:0 <<== receive message "goodbye"
        ==>>>-- NIO h_r --:7 id:2
    goodbye

    Found a channel, key:2
       -- readable 2
    =>>>>> RECV: got total:7 this total:0 cnt:-1 <<== client closes connection (cnt:-1)
    Socket closed.
    No data read.
    Show
    The debug output from my server test code when I ran mule and typed messages at the console was:   +------------------------------------+   | RAINING SOCKETS V 1.2pre0 |   | Java 1.4 Non Blocking Framework |   |....................................|   | (c) Rahul Kumar, Sep 2003. |   |....................................|   | Status: Development-beta. |   | Functional, tested to 10K,15K conns|   +------------------------------------+    Tue Nov 29 15:40:02 EST 2005 Created id: 0 Created Server Socket on:2051 -- Started -- Millis:1133296802782 Tue Nov 29 15:40:02 EST 2005 Found a channel, key:0    -- acceptable Created id: 1 =>>>>> RECV: got total:0 this total:0 cnt:0 <<== client connects to server (and immediately sends "hello") No data read. Found a channel, key:1    -- readable 1 =>>>>> RECV: got total:5 this total:5 cnt:-1 <<== receive "hello" and then client closes connection (cnt:-1 on read from select indicates client closed connection) Socket closed.     ==>>>-- NIO h_r --:5 id:1 hello Found a channel, key:0    -- acceptable Created id: 2 =>>>>> RECV: got total:0 this total:0 cnt:0 <<== client connects to server again No data read. Found a channel, key:2    -- readable 2 =>>>>> RECV: got total:7 this total:7 cnt:0 <<== receive message "goodbye"     ==>>>-- NIO h_r --:7 id:2 goodbye Found a channel, key:2    -- readable 2 =>>>>> RECV: got total:7 this total:0 cnt:-1 <<== client closes connection (cnt:-1) Socket closed. No data read.
  • Similar Issues:
    None

Description

I'm trying to write data to an external app that listens for a client connection on a tcp port and then receives multiple messages from the client using the same connection. The "keepSendSocketOpen" option does not appear to be working with Mule 1.2. In case this matters, I observed the same results when the tcp endpoint had synchronous set to true.

The org.mule.providers.tcp.TcpMessageDispatcher.java file implements "keepSendSocketOpen" for the doSend method but not for the doDispatch method. doDispatch appears to close the socket after each write.

By modifying the configuration to include
<mule-environment-properties synchronous="true"/>
the problem did not recur (although the whole model was now synchronous).

I tested this using Rahul Kumar's Raining Sockets wrapper for Java NIO (it was the fastest way to gin up a generic nonblocking server that could handle multiple client connections). I also observed the same behaviour using the clunkier java.io socket code. The code I used for my test server was:

class SocketListener {
public static void main(String[] args) {
try { MyNioSocket.setDebug(true); MyNioSocket server = new MyNioSocket(); server.create_server_socket(2051); MyNioSocket.start(); }
catch(Exception e) { e.printStackTrace(); }
}

static class MyNioSocket extends NioSocket {
public MyNioSocket() throws IOException { super(); }

public MyNioSocket(SocketChannel schannel) throws IOException { super(schannel); }

@Override
public void handle_accept(){
SocketChannel schannel = null;
MyNioSocket servsock = null;
try { schannel = this.accept(); servsock = new MyNioSocket(schannel); // RK modified on 20031012 13:30:04: added since a // connecting channel can be read from immediately. Usually // there will be a tiny request that can be handled in one // shot. servsock.handle_read(); } catch (Exception exc) { System.err.println( "Nio handle accept 675 EXC:"+ exc.toString()); exc.printStackTrace(); }

accept_accounting();
}

@Override
public void handle_close() { super.handle_close(); System.out.println("Socket closed."); }

@Override
public int handle_read() { int rc = super.handle_read(); if ( rc > 0 ) System.out.println(new String(getReadDataAsBuffer().array())); else System.out.println("No data read."); return rc; }
}
}

  1. stdout.log
    13/Dec/05 10:42 AM
    2 kB
    Rich Lucente
  2. TcpMessageDispatcher.java.patch
    13/Dec/05 10:46 AM
    5 kB
    Andrew Perepelytsya

Activity

Hide
Andrew Perepelytsya added a comment -

Fixed, commit log at http://cvs.mule.codehaus.org/changelog/mule/?cs=MAIN:andrew:20051213034356

Please retest the fix with your setup, as I don't have these on my machine.

Show
Andrew Perepelytsya added a comment - Fixed, commit log at http://cvs.mule.codehaus.org/changelog/mule/?cs=MAIN:andrew:20051213034356 Please retest the fix with your setup, as I don't have these on my machine.
Hide
Andrew Perepelytsya added a comment -

I have identified a failure in the code, which is already fixed locally, but I'm behind the firewall at the moment blocking the SSH tunnel. So, you'll have to wait at least 9 hours more till it's committed.

Show
Andrew Perepelytsya added a comment - I have identified a failure in the code, which is already fixed locally, but I'm behind the firewall at the moment blocking the SSH tunnel. So, you'll have to wait at least 9 hours more till it's committed.
Hide
Rich Lucente added a comment -

The attached output log shows that the server reused the same channel (aka connection). The problem is resolved! Thanks for the quick turnaround.

Show
Rich Lucente added a comment - The attached output log shows that the server reused the same channel (aka connection). The problem is resolved! Thanks for the quick turnaround.
Hide
Andrew Perepelytsya added a comment -

Yes, but with that code the Mule Client listener (receiver) fails. If you really want the latest version now, I'll attach the patch and commit it later to the codebase.

Show
Andrew Perepelytsya added a comment - Yes, but with that code the Mule Client listener (receiver) fails. If you really want the latest version now, I'll attach the patch and commit it later to the codebase.
Hide
Andrew Perepelytsya added a comment -

The patch against the latest codebase till I'm blocked.

Show
Andrew Perepelytsya added a comment - The patch against the latest codebase till I'm blocked.
Hide
Rich Lucente added a comment -

That's ok. I'll get the latest code tomorrow and try the test again.

Show
Rich Lucente added a comment - That's ok. I'll get the latest code tomorrow and try the test again.
Hide
Andrew Perepelytsya added a comment -
Show
Andrew Perepelytsya added a comment - Committed a fix for regression at http://cvs.mule.codehaus.org/changelog/mule/?cs=MAIN:andrew:20051214013603
Hide
Rich Lucente added a comment -

FWIW, test scenario now works correctly with 1.14 source. Thanks!

Show
Rich Lucente added a comment - FWIW, test scenario now works correctly with 1.14 source. Thanks!
Hide
Andrew Perepelytsya added a comment -

Nice, closing it.

Show
Andrew Perepelytsya added a comment - Nice, closing it.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: