I am sorry, I sent the mina-1.1.7 source just now. This is the mina-2.0.0-M1 source.
connector = new NioSocketConnector(); connector.getFilterChain().addLast(... connector.setHandler(handler); InetSocketAddress add = new InetSocketAddress(host, port); future = connector.connect(add); future.awaitUninterruptibly(); Btw, this source is not mine. I use the open source LTKJava which uses mina library. Li > Subject: RE: About the time limit of connection keeps valid from standby mode > Date: Thu, 11 Sep 2008 16:40:04 +0800 > From: [EMAIL PROTECTED] > To: [email protected] > > Hi, Li > > You write a wrong connection recovery handling block. Refer the following > code snippet if you want to make the application can work well in all cases: > > /** > * connect to specified MC identified by incoming internet address > * > * @param addr > * IP address for MC > */ > public void connectToMC(final InetSocketAddress addr) { > final ExecutorService executor = Executors.newFixedThreadPool(1); > executor.execute(new Runnable() { > public void run() { > ConnectFuture connectFuture; > try { > for (;;) { > connectFuture = connector.connect(addr); > System.out.println("tring to connect to MC: " + addr); > connectFuture.await(connectTimeout, TimeUnit.SECONDS); > if (connectFuture.isConnected()) { > System.out.println("successfully connected to MC: " > + addr); > // ... > executor.shutdown(); > return; > } > > // sleep for 5 seconds and retry > Thread.sleep(5000); > } > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > }); > } > > Here, because my app works for multiple server cluster, please throw away the > ExecutorService, just extract source code lines inside run() methods. > > BR > anderson > -----Original Message----- > From: li [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 11, 2008 4:31 PM > To: [email protected] > Subject: RE: About the time limit of connection keeps valid from standby mode > > > Hi, > > Now my program logic likes this: > 1)the client creates a connection to a server and exchanges data with server > continuously. > 2)the computer enters standby mode. > 3)bring the computer out of standby mode in about 30 minutes. > 4)the client send data to server as soon as wake up. > 5)the client receive IOException from IoHandler.exceptionCaught method. > 6)the client reconnect to server this way: > connector = new SocketConnector(); > connector.getFilterChain().addLast(..... > future = connector.connect(add,handler); > > In most cases, step 6 can recover the connection, but occasionally get the > following exception when trying to execute future.getSession(). > org.apache.mina.common.RuntimeIoException: Failed to get the session. > at > org.apache.mina.common.DefaultConnectFuture.getSession(DefaultConnectFuture.java:58) > > This problem is difficult to reproduce. > If anyone has any advice, please tell me. > Li > > _________________________________________________________________ > 秋本番!連休たくさんのこの秋、みんなのオススメ週末旅行をチェックしよう > http://clk.atdmt.com/GBL/go/112813570/direct/01/ _________________________________________________________________ 【女性版ビリー?】話題の自宅燃焼系!美しく健康的なくびれをゲット! http://clk.atdmt.com/GBL/go/112813569/direct/01/
