On 6/8/11 6:36 PM, Ireneusz Marciniak wrote:
Hi,

I'm trying to implement simple keep alive using Mina's session idle feature.
I'm using mina 2.0.1 on ubuntu 64bit with jdk 1.6.0_25.

1. What is the difference between setting the idle time like this:
connector.getSessionConfig().setBothIdleTime(5);
and like this:
session = future.getSession();
ioSessionConfig sessionConfig = session.getConfig();
sessionConfig.setBothIdleTime(5);

From the top of my head, in the first case, all the sessions will have the same idle time, in the second case, you are just setting the iddle tome for yhe current session.
2. When I set idle time to 5 seconds and keep the channel idle I can see
that idle callback is called irregularly: every 5, 6, even 7 seconds.
Is it normal?
Yes. It all depends on the polling loop, which is doing a select(1000). If you have created the session just after the beginning of the wait, you may get something like 6 s.
3. When the session is closed do I have to set the idle time to 0 to stop
the idle callback?
No, I don't think so. The callback is associated with a session.

4. I can see that the idle callback is being called from NioProcessor. Does
it mean that I should not write anything to the session in that thread?
No. The NoProcessor is just waiting 1 second before processing the idle sessions, whatever happens on the sockets. When this second is elapsed, we process the idle check, then get back to one more second waiting for incoming events. And so on.
thanks,
Irek



--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to