I have a standalone EJB Java client that is looking up my EJB and invoking remote methods. First few calls go ok but if there is an inactivity for about 5 minutes, it resets the underlying TCP connection and throws up an error. We have Spring MVC controllers that invoke JBOSS EJB in our development setup and the same problem is observed. I reproduced the problem with standalone client too. Here are code and error details:
Client code:
Context:
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"http-remoting://<myserver>:<port>");
jndiProps.put(Context.SECURITY_PRINCIPAL, "intelleza");
jndiProps.put(Context.SECURITY_CREDENTIALS, "intelleza");
jndiProps.put("jboss.naming.client.ejb.context", true);
initialContext = new InitialContext(jndiProps);
Lookup of my EJB using JNDI name in format <appname>/<ejbname>/Bean?<interface> works fine.
new Thread(new TestClient()).start();
Thread.sleep(100);
new Thread(new TestClient()).start();
Thread.sleep(60*6*1000);
new Thread(new TestClient()).start();
class ClientThread implements Runnable {
@Override
public void run() {
IUserBean uBean = (IUserBean) MyClient.doLookup(<JNDI name>);
try
{ String username = "test"; String password = "test"; System.out.println("Authentication status is " + uBean.authenticate(1, username, password)); }catch (Exception e)
{ System.out.println(e); }
}
}
First two invocations go without a problem. During third, I see this error on the client console:
20:01:59,740 DEBUG ChannelAssociation:118 - Closing channel Channel ID d838a255 (outbound) of Remoting connection 59f35920 to <dns name>/IP:Port
20:01:59,742 DEBUG RemotingConnectionEJBReceiver:184 - Closing channelChannel ID d838a255 (outbound) of Remoting connection 59f35920 to <dns name>/IP:Port
20:01:59,751 DEBUG RemoteNamingStoreV1:263 - Channel end notification received, closing channel Channel ID e890bae8 (outbound) of Remoting connection 59f35920 to <dns name>/IP:Port
20:01:59,751 INFO remoting:458 - EJBCLIENT000016: Channel Channel ID d838a255 (outbound) of Remoting connection 59f35920 to <dns name>/IP:Port can no longer process messages
I did a tcpdump (using wireshark) and I see client initiating a TCP RST during the third invocation. No errors are observed in the Wildfly console log.