I've been experimenting with dirmi, hoping to use it for a new project I'm starting. Everything works very well under normal network conditions however the network that I will be deploying the finished project on is very high latency. Typically about 800 to 1200 milliseconds. I'm unable to establish a connection to a dirmi server under those conditions.
The problem is easily reproducible, I use the tc command on my CentOS6 server to create high latency in the network adapter. For example I use the command 'tc qdisc add dev eth0 root netem delay 5000ms' to create 5 seconds of latency. That value will certainly guarantee the connect failure. Use 'tc qdisc del dev eth0 root netem' to cancel the effect.
I was using the basic RemoteExample code from the website but I added longer timeouts wherever I could. Unfortunately the problem occurs during the initial connection and we never actually make it to the user definable timeouts. Here's my test code for reference:
@timeout(120)
@TimeoutUnit(TimeUnit.SECONDS)
public interface RemoteExample extends Remote {
@timeout(120)
@TimeoutUnit(TimeUnit.SECONDS)
String talk(String name) throws RemoteException;
}
public class RemoteExampleClient {
public static void main(String[] args) throws Exception {
Environment env = new Environment();
String host = "192.168.56.101";
System.out.println("Connecting...");
Session session = env.newSessionConnector(host, 30000).connect();
RemoteExample example = (RemoteExample) session.receive(60, TimeUnit.SECONDS);
String response = example.talk("Dirmi");
System.out.println(response);
env.close();
}
}
public class RemoteExampleServer implements RemoteExample {
public static void main(String[] args) throws Exception {
Environment env = new Environment();
RemoteExample server = new RemoteExampleServer();
env.newSessionAcceptor(30000).acceptAll(server);
System.out.println("Server ready...");
}
public String talk(String name) {
return "Hello " + name;
}
}
When I run the client I receive the following error:
run:
Connecting...
Exception in thread "main" org.cojen.dirmi.ClosedException: Closed
at org.cojen.dirmi.io.PacketOutputStream.out(PacketOutputStream.java:413)
at org.cojen.dirmi.io.PacketOutputStream.write(PacketOutputStream.java:91)
at java.io.ObjectOutputStream$BlockDataOutputStream.writeBlockHeader(ObjectOutputStream.java:1889)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1874)
at java.io.ObjectOutputStream$BlockDataOutputStream.flush(ObjectOutputStream.java:1821)
at java.io.ObjectOutputStream.flush(ObjectOutputStream.java:718)
at org.cojen.dirmi.core.InvocationOutputStream.flush(InvocationOutputStream.java:276)
at org.cojen.dirmi.core.StandardSession.(StandardSession.java:380)
at org.cojen.dirmi.core.StandardSession.create(StandardSession.java:215)
at org.cojen.dirmi.core.StandardSession.create(StandardSession.java:202)
at org.cojen.dirmi.Environment.newSession(Environment.java:334)
at org.cojen.dirmi.Environment$SocketConnector.connect(Environment.java:560)
at dtsimple.RemoteExampleClient.main(RemoteExampleClient.java:12)
Java Result: 1
I've tried poking around in the source to see why that stream is being closed but haven't tracked down the problem yet. Is there some setting I should tweak or something else I'm missing? Any help or insights would be greatly appreciated. If I can get this to work, I think this library is going to be perfect for my project.
Thanks!