2016-07-13 49 views
1

我正在使用以下代碼在java applet中使用遠程連接。遠程連接在蜻蜓一段時間後掉線

Hashtable jndiProps = new Hashtable<Object,Object>(); 
    jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
    jndiProps.put(Context.PROVIDER_URL, "http-remoting://" + myhost + ":" + "8080"); 
    jndiProps.put("jboss.naming.client.ejb.context", true); 
    jndiProps.put("org.jboss.ejb.client.scoped.context", true);; 
    //jndiProps.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming"); 
    jndiProps.put("endpoint.name", "client-endpoint"); 
    jndiProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", false); 
    jndiProps.put("remote.connections", "default"); 
    jndiProps.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", false); 
    jndiProps.put("remote.connection.default.host", myhost); 
    jndiProps.put("remote.connection.default.port", "8080"); 
    jndiProps.put(Context.SECURITY_PRINCIPAL, "demouser"); 
    jndiProps.put(Context.SECURITY_CREDENTIALS, "demouser123"); 
    InitialContext ctx = null; 
    try { 
     ctx = new InitialContext(jndiProps); 
    } catch(NamingException nex) { 
     nex.printStackTrace(); 
    } catch(Exception ex) { 
     ex.printStackTrace(); 
    } 
    RemoteInterface remote = (RemoteInterface)ctx.lookup(ejbUrl); 

這裏SECURITY_PRINCIPAL是使用add-user.sh腳本創建的。該applet加載,一切正常。但有時在Java控制檯後,會出現一條消息說

2016年7月13日下午3時04分21秒org.jboss.ejb.client.remoting.ChannelAssociation $ ResponseReceiver handleEnd 信息:EJBCLIENT000016:通道通道ID 98a848d6 (出站)遠程連接22d8b2a8到cms8sf.cdotd.ernet.in/192.168.5.240:8080不能再處理消息。

然後,每當我嘗試訪問拋出的任何遠程bean異常的方法。

java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:app, moduleName:app-ejb, distinctName:] combination for invocation context [email protected] 
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:774) 

我很不確定爲什麼會發生這種情況。有人可以幫幫我嗎。預先感謝。 我使用java 1.8和wildfly 9.0.2。

回答

0

也許,這個選項會幫助你

remote.connection.default.connect.options.org.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL = 5000

它是某種平