Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2
-
Fix Version/s: 2.0.0-M1
-
Component/s: Transport: TCP / UDP / SSL / Multicast
-
Labels:None
-
Environment:
Mule 1.2, Windows 2000 SP4, and Java JDK 1.5.0_05
-
Configuration:
-
Log Output:
-
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;
}
}
}
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.