Ghost sessions are a result of a broken TCP connection. It is possible that the client lost internet connection and was unable to correctly terminate the TCP session. Therefore, your application will never get a TCP close until the default idleness timer invokes or you use Mina's internal idleness to close sessions.
On Mon, May 11, 2015 at 2:33 AM, 白玉雄 <ba...@17car.com.cn> wrote: > Hi, > I print all attributes of a bug session as follow, Mina processes the > last request at 2015-05-11 01:58:34, then stucked and no request is > processed afterwards. > > > namevalue > getWrittenBytesThroughput0.0 > getLastIoTime2015-05-11 02:23:11 > getReadBytes5971 > getReadBytesThroughput0.0 > isConnectedtrue > getLastWriterIdleTime2015-05-11 01:58:34 > isWriterIdlefalse > getReaderIdleCount0 > getLocalAddress/xx.xx.xx.xx:xxxx > getWriterIdleCount0 > getWrittenMessagesThroughput0.0 > ID3233 > getServiceAddress/0.0.0.0:xxxxx > getReadMessages30 > getLastReadTime2015-05-11 02:08:48 > isSecuredfalse > isReaderIdlefalse > getLastReaderIdleTime2015-05-11 01:58:34 > getWrittenBytes2221 > getRemoteAddress/xx.xx.xx.xx:xxxxx > getReadMessagesThroughput0.0 > isBothIdlefalse > isReadSuspendedfalse > getScheduledWriteMessages-39 > getLastWriteTime2015-05-11 02:23:11 > getCreationTime2015-05-11 01:58:34 > getBothIdleCount0 > getLastBothIdleTime2015-05-11 01:58:34 > isWriteSuspendedfalse > isClosingfalse > getWrittenMessages39 > > ------------------ Original ------------------ > From: "白玉雄"<ba...@17car.com.cn>; > Date: Wed, May 6, 2015 02:47 PM > To: "users"<users@mina.apache.org>; > > Subject: Re: How to debug ghost sessions > > > I am sure that idle event is fired. After no heartbeat for 900 seconds , > session was closed by server. > > ------------------ Original ------------------ > From: "Emmanuel Lécharny"<elecha...@gmail.com>; > Date: Wed, May 6, 2015 02:31 PM > To: "users"<users@mina.apache.org>; > > Subject: Re: How to debug ghost sessions > > > Le 06/05/15 05:24, 白玉雄 a écrit : > > Hi all, > > My mina server neither process session request nor disconnect the > session as idle. and this happens only on few of sessions, most of them > works well. > > > > > > Some Code: > > public void run(int port) throws IOException { > > this.acceptor = new NioSocketAcceptor(); > > this.acceptor.setReuseAddress(true); > > > > > > this.acceptor.getFilterChain().addLast("codec",new > ProtocolCodecFilter(new ClwMessageProtocolCodecFactory())); > > > > > > this.acceptor.getFilterChain().addLast("logger", new > LoggingFilter()); > > this.acceptor.getFilterChain().addLast("threadPool", new > ExecutorFilter(new > UnorderedThreadPoolExecutor(PropertiesHander.getInt("MAXIMUM_POOL_SIZE", > 16)))); > > > > > > this.acceptor.getSessionConfig().setReadBufferSize(512); > > this.acceptor.getSessionConfig().setReceiveBufferSize(512); > > // set idle time, default 900 seconds > > > > this.acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE,PropertiesHander.getInt("SESSION_IDLE_TIME",900)); > > this.acceptor.setHandler(ioHandler); > > this.acceptor.bind(new InetSocketAddress(port)); > > LOGGER.info("Socket server Listening on port "+ > PropertiesHander.getInt("SERVER_PORT", port)); > > } > > > > > > > > Some phenomenons: > > 1、The ghost session can be found by > this.acceptor.getManagedSessions().get(sessionId) > > 2、If force the client disconnect from server and reconnect again, the > client now works well and request was processed normally. > > > > It seems that the session was stucked. > > > > > > Question: > > Why this happens > No idea... You aren't providing enough information to know what's going on. > > > and How to reappear and debug this? > Setting the idle time is good, but at some point you must check the > event that is fired when teh session has been idle for 900 seconds. Are > you doing that ? >