You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Alex Liu (JIRA)" <ji...@apache.org> on 2009/07/21 09:17:14 UTC

[jira] Closed: (DIRMINA-731) Problem on IoSession.getReaderIdleCount() and IoSession.getWriterIdleCount()

     [ https://issues.apache.org/jira/browse/DIRMINA-731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Liu closed DIRMINA-731.
----------------------------

    Resolution: Fixed

I missed up....
I should call setIdleTime with IdleStatus.READER_IDLE first...

> Problem on IoSession.getReaderIdleCount() and IoSession.getWriterIdleCount()
> ----------------------------------------------------------------------------
>
>                 Key: DIRMINA-731
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-731
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M6
>         Environment: Windows server 2003
>            Reporter: Alex Liu
>
> Hi everyone,
> I got a problem when I use IoSession.getReaderIdleCount() and
> IoSession.getWriterIdleCount(). Please can anyone just do a fever to
> me? Thanks!
> The problem is: When I call IoSession.getReaderIdleCount() and
> IoSession.getWriterIdleCount(), they just return "0" as a result but
> when I call IoSession.getIdleCount(), the result is no problem
> (increases itself).
> Below is my main class:
> import java.io.IOException;
> import java.net.InetSocketAddress;
> import java.nio.charset.Charset;
> import org.apache.log4j.Logger;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.mina.core.service.IoAcceptor;
> import org.apache.mina.core.session.IdleStatus;
> import org.apache.mina.filter.codec.ProtocolCodecFilter;
> import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
> import org.apache.mina.filter.logging.LoggingFilter;
> import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
> import org.apache.mina.filter.codec.textline.LineDelimiter;
> public class MinaTimeServer {
>        private static int PORT = 8888;
>        private static Logger logger = Logger.getLogger
> (MinaTimeServer.class);
>        public static void main(String[] args) throws IOException {
>                PropertyConfigurator.configure("log4j.properties");
>                IoAcceptor acceptor = new NioSocketAcceptor();
>                LoggingFilter loggingFilter = new LoggingFilter();
>                acceptor.getFilterChain().addLast("logger", loggingFilter);
>                TextLineCodecFactory codecFactory = new TextLineCodecFactory(Charset
>                                .forName("UTF-8"), LineDelimiter.NUL.getValue(),
>                                LineDelimiter.NUL.getValue());
>                acceptor.getFilterChain().addLast("codec",
>                                new ProtocolCodecFilter(codecFactory));
>                acceptor.setHandler(new TimeServerHandler());
>                acceptor.getSessionConfig().setReadBufferSize(2048);
>                acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 2);
>                acceptor.bind(new InetSocketAddress(PORT));
>                logger.info("Listen port: " + PORT);
>        }
> }
> Below is my Handler class:
> import java.util.Date;
> import org.apache.log4j.*;
> import org.apache.mina.core.session.IdleStatus;
> import org.apache.mina.core.service.IoHandlerAdapter;
> import org.apache.mina.core.session.IoSession;
> public class TimeServerHandler extends IoHandlerAdapter {
>        private static Logger logger = Logger.getLogger(TimeServerHandler.class);
>        @Override
>        public void exceptionCaught(IoSession session, Throwable cause)
>                        throws Exception {
>                cause.printStackTrace();
>        }
>        @Override
>        public void sessionIdle(IoSession session, IdleStatus status)
>                        throws Exception {
>                logger.info(session.getId()+"-IDLE " +session.getReaderIdleCount());
>        }
> }
> Is there anything wrong in my code? Thanks for your help again!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.