You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by 李 翠竹 <cu...@live.jp> on 2008/09/11 03:48:49 UTC

About the time limit of connection keeps valid from standby mode

Hi,
I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
My test case is like this:
OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2
Mina version:2.0.0-M1
Step:
1)My client program creates a connection to a server by using SocketConnector.
2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
3)Bring the computer out of standby mode after a time.
I found the connection would be valid or invalid, according to the standby time.
If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
java.io.IOException: An existing connection was forcibly closed by the remote host.

I want to learn:
1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
2)Could I set this time limit?

Thanks,
Li

_________________________________________________________________
秋本番!連休たくさんのこの秋、みんなのオススメ週末旅行をチェックしよう
http://clk.atdmt.com/GBL/go/112813570/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
Hi, Emmanuel

You are right. in most simple cases, there is no need to offer heart beat mechanism, because MINA already provides network exception handle logic for programmer to customization.
I mean, IoHandler.exceptionCaught() could be the right place to process most exception cases, including the exception when write bytes to a closed or invalid socket channel.

Sure, as you suggest, detect if socket is open or not seems like a good way. But, please notice that it can't guarantee that the network packet can arrive to other peer because of
other kind of network errors. E.g. Throtting, internal exception like that. So, I strongly recommend to use exceptionCaught() method to perform network exception handling.

BR

-----Original Message-----
From: Emmanuel Lecharny [mailto:elecharny@gmail.com] 
Sent: Thursday, September 11, 2008 2:58 PM
To: users@mina.apache.org
Subject: Re: About the time limit of connection keeps valid from standby mode

Hi,

you may also decide not to use a heart beat mechanism at all, but simply use the sent message to check if the connection is still open or not. If it's not, you will get an exception, then you can handle this exception, reopen the connection, and resend the data.

Anyway, Wentrui Guo is right : it's all about adopting the strategy which fits best with your application.

Wenrui Guo wrote:
> Hi, Allen
>
> In fact, you refer a very common question on strategy about How to program the heart-beat logic. I'll explain the topic in detail thus you can choose the best way for you.
>
> >From the perspective of direction, heart beat can be divided into two 
> >categories: Bidirectional or Undirectional. Which means if each peer 
> >on the communication channel should
> Send out heart beat package to the other side or not. If both of 
> client and servier side need to send out hear beat, then we call it Bidirectional, otherwise Undirectional. Of course, Undirectional is the simplest way as you see because less effort to implement it.
>
> Heat beat can be separated to other ways by when the heat beat need to 
> be issued. Some sorts of commercial protocol choose fixed interval to 
> produce heart beat packet, individual thread is absolutely most intuitive candidate. But for other cases, I strongly recommend you to select another way, because in my opinion it conforms to the spirit of hear beat and moreover, also be a better performance manner. Sure, that's also an easy way because MINA already integrate the feature with core framework.
>
> As you know, sessionIdle() is triggered by IdleStatusChecker that is a separate daemon thread keep on running during the lifetime of MINA application. If idle events arise, either because of read event or write event, sometimes maybe both read/write event, heart beat should be sent to detect if the other peer is still alive. If no associated heart beat response message is received, then mark the situation and try to resend once more, until you believe the other side is not exist anymore.
>
> In conclusion, depends on strategy you like, there are many ways available. The way you choose really depends on the situtation and what do you want to achieve.
>
> BR
> anderson
>
> -----Original Message-----
> From: Allen Jiang [mailto:allenj@hz.webex.com]
> Sent: Thursday, September 11, 2008 2:03 PM
> To: Wenrui Guo
> Cc: users@mina.apache.org
> Subject: Re: About the time limit of connection keeps valid from 
> standby mode
>
> hi,Anderson Guo,
>    if we use heart-beat detection mechanism,is it suitable to send heart-beat when the session is idle as follows:
>
>  public void sessionIdle(IoSession iosession, IdleStatus idlestatus){ heartBeat(); } if not,should we new a thread to use heart-beat detection mechanism ?
>
> Best Regards
> Allen Jiang
>
> ----- Original Message -----
> From: "Wenrui Guo" <we...@ericsson.com>
> To: <us...@mina.apache.org>
> Sent: Thursday, September 11, 2008 1:50 PM
> Subject: RE: About the time limit of connection keeps valid from 
> standby mode
>
>
> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>
> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>
> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>
> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>
> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>
> Best Regards
> Anderson Guo
>
> -----Original Message-----
> From: Allen Jiang [mailto:allenj@hz.webex.com]
> Sent: Thursday, September 11, 2008 1:17 PM
> To: users@mina.apache.org
> Subject: Re: About the time limit of connection keeps valid from 
> standby mode
>
> Hi,�� ����,
>    Maybe you could check whether you have set the session to be closed when the session's idle event is activated in your server  site.
>
> Yahoo ID:allen_jiangguilong
>
> ----- Original Message -----
> From: "�� ����" <cu...@live.jp>
> To: <us...@mina.apache.org>
> Sent: Thursday, September 11, 2008 9:48 AM
> Subject: About the time limit of connection keeps valid from standby 
> mode
>
>
>   
>> Hi,
>> I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
>> My test case is like this:
>> OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2 Mina 
>> version:2.0.0-M1
>> Step:
>> 1)My client program creates a connection to a server by using SocketConnector.
>> 2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
>> 3)Bring the computer out of standby mode after a time.
>> I found the connection would be valid or invalid, according to the standby time.
>> If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
>> Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
>> java.io.IOException: An existing connection was forcibly closed by the remote host.
>>
>> I want to learn:
>> 1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
>> 2)Could I set this time limit?
>>
>> Thanks,
>> Li
>>
>> _________________________________________________________________
>> �ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
>> http://clk.atdmt.com/GBL/go/112813570/direct/01/
>>     
>
>   


--
--
cordialement, regards,
Emmanuel L��charny
www.iktek.com
directory.apache.org



Re: About the time limit of connection keeps valid from standby mode

Posted by Emmanuel Lecharny <el...@gmail.com>.
Hi,

you may also decide not to use a heart beat mechanism at all, but simply
use the sent message to check if the connection is still open or not. If
it's not, you will get an exception, then you can handle this exception,
reopen the connection, and resend the data.

Anyway, Wentrui Guo is right : it's all about adopting the strategy
which fits best with your application.

Wenrui Guo wrote:
> Hi, Allen
>
> In fact, you refer a very common question on strategy about How to program the heart-beat logic. I'll explain the topic in detail thus you can choose the best way for you.
>
> >From the perspective of direction, heart beat can be divided into two categories: Bidirectional or Undirectional. Which means if each peer on the communication channel should
> Send out heart beat package to the other side or not. If both of client and servier side need to send out hear beat, then we call it Bidirectional, otherwise Undirectional. Of course,
> Undirectional is the simplest way as you see because less effort to implement it.
>
> Heat beat can be separated to other ways by when the heat beat need to be issued. Some sorts of commercial protocol choose fixed interval to produce heart beat packet, individual thread
> is absolutely most intuitive candidate. But for other cases, I strongly recommend you to select another way, because in my opinion it conforms to the spirit of hear beat and moreover, also
> be a better performance manner. Sure, that's also an easy way because MINA already integrate the feature with core framework.
>
> As you know, sessionIdle() is triggered by IdleStatusChecker that is a separate daemon thread keep on running during the lifetime of MINA application. If idle events arise, either because of read event or write event, sometimes maybe both read/write event, heart beat should be sent to detect if the other peer is still alive. If no associated heart beat response message is received, then mark the situation and try to resend once more, until you believe the other side is not exist anymore.
>
> In conclusion, depends on strategy you like, there are many ways available. The way you choose really depends on the situtation and what do you want to achieve.
>
> BR
> anderson 
>
> -----Original Message-----
> From: Allen Jiang [mailto:allenj@hz.webex.com] 
> Sent: Thursday, September 11, 2008 2:03 PM
> To: Wenrui Guo
> Cc: users@mina.apache.org
> Subject: Re: About the time limit of connection keeps valid from standby mode
>
> hi,Anderson Guo,
>    if we use heart-beat detection mechanism,is it suitable to send heart-beat when the session is idle as follows:
>
>  public void sessionIdle(IoSession iosession, IdleStatus idlestatus){ heartBeat(); } if not,should we new a thread to use heart-beat detection mechanism ?
>
> Best Regards
> Allen Jiang
>
> ----- Original Message -----
> From: "Wenrui Guo" <we...@ericsson.com>
> To: <us...@mina.apache.org>
> Sent: Thursday, September 11, 2008 1:50 PM
> Subject: RE: About the time limit of connection keeps valid from standby mode
>
>
> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>
> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>
> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>
> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>
> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>
> Best Regards
> Anderson Guo
>
> -----Original Message-----
> From: Allen Jiang [mailto:allenj@hz.webex.com] 
> Sent: Thursday, September 11, 2008 1:17 PM
> To: users@mina.apache.org
> Subject: Re: About the time limit of connection keeps valid from standby mode
>
> Hi,�� ����,
>    Maybe you could check whether you have set the session to be closed when the session's idle event is activated in your server  site.
>
> Yahoo ID:allen_jiangguilong 
>
> ----- Original Message -----
> From: "�� ����" <cu...@live.jp>
> To: <us...@mina.apache.org>
> Sent: Thursday, September 11, 2008 9:48 AM
> Subject: About the time limit of connection keeps valid from standby mode
>
>
>   
>> Hi,
>> I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
>> My test case is like this:
>> OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2
>> Mina version:2.0.0-M1
>> Step:
>> 1)My client program creates a connection to a server by using SocketConnector.
>> 2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
>> 3)Bring the computer out of standby mode after a time.
>> I found the connection would be valid or invalid, according to the standby time.
>> If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
>> Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
>> java.io.IOException: An existing connection was forcibly closed by the remote host.
>>
>> I want to learn:
>> 1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
>> 2)Could I set this time limit?
>>
>> Thanks,
>> Li
>>
>> _________________________________________________________________
>> �ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
>> http://clk.atdmt.com/GBL/go/112813570/direct/01/
>>     
>
>   


-- 
--
cordialement, regards,
Emmanuel L��charny
www.iktek.com
directory.apache.org



RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
Hi, Allen

In fact, you refer a very common question on strategy about How to program the heart-beat logic. I'll explain the topic in detail thus you can choose the best way for you.

>From the perspective of direction, heart beat can be divided into two categories: Bidirectional or Undirectional. Which means if each peer on the communication channel should
Send out heart beat package to the other side or not. If both of client and servier side need to send out hear beat, then we call it Bidirectional, otherwise Undirectional. Of course,
Undirectional is the simplest way as you see because less effort to implement it.

Heat beat can be separated to other ways by when the heat beat need to be issued. Some sorts of commercial protocol choose fixed interval to produce heart beat packet, individual thread
is absolutely most intuitive candidate. But for other cases, I strongly recommend you to select another way, because in my opinion it conforms to the spirit of hear beat and moreover, also
be a better performance manner. Sure, that's also an easy way because MINA already integrate the feature with core framework.

As you know, sessionIdle() is triggered by IdleStatusChecker that is a separate daemon thread keep on running during the lifetime of MINA application. If idle events arise, either because of read event or write event, sometimes maybe both read/write event, heart beat should be sent to detect if the other peer is still alive. If no associated heart beat response message is received, then mark the situation and try to resend once more, until you believe the other side is not exist anymore.

In conclusion, depends on strategy you like, there are many ways available. The way you choose really depends on the situtation and what do you want to achieve.

BR
anderson 

-----Original Message-----
From: Allen Jiang [mailto:allenj@hz.webex.com] 
Sent: Thursday, September 11, 2008 2:03 PM
To: Wenrui Guo
Cc: users@mina.apache.org
Subject: Re: About the time limit of connection keeps valid from standby mode

hi,Anderson Guo,
   if we use heart-beat detection mechanism,is it suitable to send heart-beat when the session is idle as follows:

 public void sessionIdle(IoSession iosession, IdleStatus idlestatus){ heartBeat(); } if not,should we new a thread to use heart-beat detection mechanism ?

Best Regards
Allen Jiang

----- Original Message -----
From: "Wenrui Guo" <we...@ericsson.com>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 1:50 PM
Subject: RE: About the time limit of connection keeps valid from standby mode


I am not sure if I understand your issue, but I would like to share my opinion with you about it:

First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).

Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.

Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.

BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.

Best Regards
Anderson Guo

-----Original Message-----
From: Allen Jiang [mailto:allenj@hz.webex.com] 
Sent: Thursday, September 11, 2008 1:17 PM
To: users@mina.apache.org
Subject: Re: About the time limit of connection keeps valid from standby mode

Hi,�� ����,
   Maybe you could check whether you have set the session to be closed when the session's idle event is activated in your server  site.

Yahoo ID:allen_jiangguilong 

----- Original Message -----
From: "�� ����" <cu...@live.jp>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 9:48 AM
Subject: About the time limit of connection keeps valid from standby mode


> 
> Hi,
> I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
> My test case is like this:
> OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2
> Mina version:2.0.0-M1
> Step:
> 1)My client program creates a connection to a server by using SocketConnector.
> 2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
> 3)Bring the computer out of standby mode after a time.
> I found the connection would be valid or invalid, according to the standby time.
> If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
> Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
> java.io.IOException: An existing connection was forcibly closed by the remote host.
> 
> I want to learn:
> 1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
> 2)Could I set this time limit?
> 
> Thanks,
> Li
> 
> _________________________________________________________________
> �ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
> http://clk.atdmt.com/GBL/go/112813570/direct/01/

Re: About the time limit of connection keeps valid from standby mode

Posted by Allen Jiang <al...@hz.webex.com>.
hi,Anderson Guo,
   if we use heart-beat detection mechanism,is it suitable to send heart-beat when the session is idle as follows:

 public void sessionIdle(IoSession iosession, IdleStatus idlestatus){
heartBeat();
}
if not,should we new a thread to use heart-beat detection mechanism ?

Best Regards
Allen Jiang

----- Original Message ----- 
From: "Wenrui Guo" <we...@ericsson.com>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 1:50 PM
Subject: RE: About the time limit of connection keeps valid from standby mode


I am not sure if I understand your issue, but I would like to share my opinion with you about it:

First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).

Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.

Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.

BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.

Best Regards
Anderson Guo

-----Original Message-----
From: Allen Jiang [mailto:allenj@hz.webex.com] 
Sent: Thursday, September 11, 2008 1:17 PM
To: users@mina.apache.org
Subject: Re: About the time limit of connection keeps valid from standby mode

Hi,�� ����,
   Maybe you could check whether you have set the session to be closed when the session's idle event is activated in your server  site.

Yahoo ID:allen_jiangguilong 

----- Original Message -----
From: "�� ����" <cu...@live.jp>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 9:48 AM
Subject: About the time limit of connection keeps valid from standby mode


> 
> Hi,
> I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
> My test case is like this:
> OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2
> Mina version:2.0.0-M1
> Step:
> 1)My client program creates a connection to a server by using SocketConnector.
> 2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
> 3)Bring the computer out of standby mode after a time.
> I found the connection would be valid or invalid, according to the standby time.
> If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
> Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
> java.io.IOException: An existing connection was forcibly closed by the remote host.
> 
> I want to learn:
> 1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
> 2)Could I set this time limit?
> 
> Thanks,
> Li
> 
> _________________________________________________________________
> �ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
> http://clk.atdmt.com/GBL/go/112813570/direct/01/

Re: About the time limit of connection keeps valid from standby mode

Posted by Emmanuel Lecharny <el...@gmail.com>.
li wrote:
> Thanks for all replies.
>
> I think I have got the answer although a little regret.
>
>   
There is nothing to regret : when it's impossible, it's impossible ;)

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



RE: About the time limit of connection keeps valid from standby mode

Posted by li <cu...@live.jp>.
Hi, anderson

Thanks.  I will try it.

Regards,

Li


> Subject: RE: About the time limit of connection keeps valid from standby mode
> Date: Thu, 11 Sep 2008 17:10:12 +0800
> From: wenrui.guo@ericsson.com
> To: users@mina.apache.org
>
> Hi, Li
>
> It doesn't matter, just use the similar code I represented as below.
>
> It could be applied to MINA 1.x and MINA 2.x. I saw the source code change between 1.7 and 2.0-M1. :P
>
> BR
> anderson
>
> -----Original Message-----
> From: li [mailto:cuizhu.li@live.jp]
> Sent: Thursday, September 11, 2008 5:03 PM
> To: users@mina.apache.org
> Subject: RE: About the time limit of connection keeps valid from standby mode
>
>
> 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: wenrui.guo@ericsson.com
>> To: users@mina.apache.org
>>
>> 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:cuizhu.li@live.jp]
>> Sent: Thursday, September 11, 2008 4:31 PM
>> To: users@mina.apache.org
>> 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(DefaultConnectF
>> uture.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/

_________________________________________________________________
あなたが困ったことは日本の誰かも困ってる?相談箱で調べてみよう!
http://clk.atdmt.com/GBL/go/112817927/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
Hi, Li

It doesn't matter, just use the similar code I represented as below. 

It could be applied to MINA 1.x and MINA 2.x. I saw the source code change between 1.7 and 2.0-M1. :P

BR
anderson 

-----Original Message-----
From: li [mailto:cuizhu.li@live.jp] 
Sent: Thursday, September 11, 2008 5:03 PM
To: users@mina.apache.org
Subject: RE: About the time limit of connection keeps valid from standby mode


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: wenrui.guo@ericsson.com
> To: users@mina.apache.org
>
> 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:cuizhu.li@live.jp]
> Sent: Thursday, September 11, 2008 4:31 PM
> To: users@mina.apache.org
> 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(DefaultConnectF
> uture.java:58)
>
> This problem is difficult to reproduce.
> If anyone has any advice, please tell me.
> Li
>
> _________________________________________________________________
> �ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
> http://clk.atdmt.com/GBL/go/112813570/direct/01/

_________________________________________________________________
��Ů�԰�ӥ�`����Ԓ�}����լȼ��ϵ�������������Ĥʤ��Ӥ�򥲥åȣ�
http://clk.atdmt.com/GBL/go/112813569/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by li <cu...@live.jp>.
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: wenrui.guo@ericsson.com
> To: users@mina.apache.org
>
> 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:cuizhu.li@live.jp]
> Sent: Thursday, September 11, 2008 4:31 PM
> To: users@mina.apache.org
> 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/

RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
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:cuizhu.li@live.jp] 
Sent: Thursday, September 11, 2008 4:31 PM
To: users@mina.apache.org
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

_________________________________________________________________
�ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
http://clk.atdmt.com/GBL/go/112813570/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by li <cu...@live.jp>.
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/

RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
I want to remind you that you should master the convention in asychronous network programming. There are several important principles that essential for all programmers who want to write high performance and asychrnous based application.

Don't feel sad, because that's the rule in async world.

BR
anderson 

-----Original Message-----
From: li [mailto:cuizhu.li@live.jp] 
Sent: Thursday, September 11, 2008 3:41 PM
To: users@mina.apache.org
Subject: RE: About the time limit of connection keeps valid from standby mode


Thanks for all replies.

I think I have got the answer although a little regret.

Li


> From: allenj@hz.webex.com
> To: users@mina.apache.org
> Subject: Re: About the time limit of connection keeps valid from 
> standby mode
> Date: Thu, 11 Sep 2008 15:23:36 +0800
>
> I agree with Anderson .
>
> ----- Original Message -----
> From: "Wenrui Guo" 
> To: 
> Sent: Thursday, September 11, 2008 3:19 PM
> Subject: RE: About the time limit of connection keeps valid from 
> standby mode
>
>
> Hi, Li
>
> I wonder if you understanding my explanation. But in order to make the question more clear, I will just focus on the proposal you mentioned.
> First, there is no parameter that control the validation of socket connection (Maybe some OS experts will challenge me, but please forget it because you can't use it in Java Runtime Environment) .
> Second, even if you could retrieve the parameter, you can't ensure the 
> connection must change to invalid(close) at that moment, so your solution is impossible to apply. For the case, as I said before, Just write your exception handling code and retry.
>
> BR
> anderson
>
> -----Original Message-----
> From: li [mailto:cuizhu.li@live.jp]
> Sent: Thursday, September 11, 2008 2:47 PM
> To: users@mina.apache.org
> Subject: RE: About the time limit of connection keeps valid from 
> standby mode
>
>
> Hi, Anderson Guo,
>
> Thanks for your reply.
>
> As you guess, my connection is a long-term connection and I hope it can recover as soon as the computer resumes from a standby mode.
>
> In standby mode, I think all programs and connections would go to sleep and also the heart-beat detection mechanism.
>
> I want to know if there are some parameters (e.g. mina parameters, java vm parameters, or os parameters), which calculate the time limit of the connection becoming invalid.
>
> Regards,
>
> Li
>
>
>
>> Subject: RE: About the time limit of connection keeps valid from 
>> standby mode
>> Date: Thu, 11 Sep 2008 13:50:05 +0800
>> From: wenrui.guo@ericsson.com
>> To: users@mina.apache.org
>>
>> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>>
>> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>>
>> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>>
>> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>>
>> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>>
>> Best Regards
>> Anderson Guo
>>
>
> _________________________________________________________________
> ��Ů�԰�ӥ�`����Ԓ�}����լȼ��ϵ�������������Ĥʤ��Ӥ�򥲥åȣ�
> http://clk.atdmt.com/GBL/go/112813569/direct/01/

_________________________________________________________________
Hotmail ��ʹ���νԘ������˵́���֥��`�ɥХ�ɥ��`�ӥ���
http://campaign.live.jp/eaccess/Top/

RE: About the time limit of connection keeps valid from standby mode

Posted by li <cu...@live.jp>.
Thanks for all replies.

I think I have got the answer although a little regret.

Li


> From: allenj@hz.webex.com
> To: users@mina.apache.org
> Subject: Re: About the time limit of connection keeps valid from standby mode
> Date: Thu, 11 Sep 2008 15:23:36 +0800
>
> I agree with Anderson .
>
> ----- Original Message -----
> From: "Wenrui Guo" 
> To: 
> Sent: Thursday, September 11, 2008 3:19 PM
> Subject: RE: About the time limit of connection keeps valid from standby mode
>
>
> Hi, Li
>
> I wonder if you understanding my explanation. But in order to make the question more clear, I will just focus on the proposal you mentioned.
> First, there is no parameter that control the validation of socket connection (Maybe some OS experts will challenge me, but please forget it because you can't use it in Java Runtime Environment) .
> Second, even if you could retrieve the parameter, you can't ensure the connection must change to invalid(close) at that moment, so your solution is impossible to apply. For the case, as I said before,
> Just write your exception handling code and retry.
>
> BR
> anderson
>
> -----Original Message-----
> From: li [mailto:cuizhu.li@live.jp]
> Sent: Thursday, September 11, 2008 2:47 PM
> To: users@mina.apache.org
> Subject: RE: About the time limit of connection keeps valid from standby mode
>
>
> Hi, Anderson Guo,
>
> Thanks for your reply.
>
> As you guess, my connection is a long-term connection and I hope it can recover as soon as the computer resumes from a standby mode.
>
> In standby mode, I think all programs and connections would go to sleep and also the heart-beat detection mechanism.
>
> I want to know if there are some parameters (e.g. mina parameters, java vm parameters, or os parameters), which calculate the time limit of the connection becoming invalid.
>
> Regards,
>
> Li
>
>
>
>> Subject: RE: About the time limit of connection keeps valid from
>> standby mode
>> Date: Thu, 11 Sep 2008 13:50:05 +0800
>> From: wenrui.guo@ericsson.com
>> To: users@mina.apache.org
>>
>> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>>
>> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>>
>> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>>
>> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>>
>> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>>
>> Best Regards
>> Anderson Guo
>>
>
> _________________________________________________________________
> 【女性版ビリー?】話題の自宅燃焼系!美しく健康的なくびれをゲット!
> http://clk.atdmt.com/GBL/go/112813569/direct/01/

_________________________________________________________________
Hotmail をお使いの皆様だけに低価格ブロードバンドサービス!
http://campaign.live.jp/eaccess/Top/

Re: About the time limit of connection keeps valid from standby mode

Posted by Allen Jiang <al...@hz.webex.com>.
I agree with Anderson .

----- Original Message ----- 
From: "Wenrui Guo" <we...@ericsson.com>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 3:19 PM
Subject: RE: About the time limit of connection keeps valid from standby mode


Hi, Li

I wonder if you understanding my explanation. But in order to make the question more clear, I will just focus on the proposal you mentioned.
First, there is no parameter that control the validation of socket connection (Maybe some OS experts will challenge me, but please forget it because you can't use it in Java Runtime Environment) .
Second, even if you could retrieve the parameter, you can't ensure the connection must change to invalid(close) at that moment, so your solution is impossible to apply. For the case, as I said before,
Just write your exception handling code and retry.

BR
anderson

-----Original Message-----
From: li [mailto:cuizhu.li@live.jp] 
Sent: Thursday, September 11, 2008 2:47 PM
To: users@mina.apache.org
Subject: RE: About the time limit of connection keeps valid from standby mode


Hi, Anderson Guo,

Thanks for your reply.

As you guess, my connection is a long-term connection and I hope it can recover as soon as the computer resumes from a standby mode.

In standby mode, I think all programs and connections would go to sleep and also the heart-beat detection mechanism.

I want to know if there are some parameters (e.g. mina parameters, java vm parameters, or os parameters), which calculate the time limit of the connection becoming invalid.

Regards,

Li



> Subject: RE: About the time limit of connection keeps valid from 
> standby mode
> Date: Thu, 11 Sep 2008 13:50:05 +0800
> From: wenrui.guo@ericsson.com
> To: users@mina.apache.org
>
> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>
> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>
> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>
> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>
> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>
> Best Regards
> Anderson Guo
>

_________________________________________________________________
��Ů�԰�ӥ�`����Ԓ�}����լȼ��ϵ�������������Ĥʤ��Ӥ�򥲥åȣ�
http://clk.atdmt.com/GBL/go/112813569/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
Hi, Li

I wonder if you understanding my explanation. But in order to make the question more clear, I will just focus on the proposal you mentioned.
First, there is no parameter that control the validation of socket connection (Maybe some OS experts will challenge me, but please forget it because you can't use it in Java Runtime Environment) .
Second, even if you could retrieve the parameter, you can't ensure the connection must change to invalid(close) at that moment, so your solution is impossible to apply. For the case, as I said before,
Just write your exception handling code and retry.

BR
anderson

-----Original Message-----
From: li [mailto:cuizhu.li@live.jp] 
Sent: Thursday, September 11, 2008 2:47 PM
To: users@mina.apache.org
Subject: RE: About the time limit of connection keeps valid from standby mode


Hi, Anderson Guo,

Thanks for your reply.

As you guess, my connection is a long-term connection and I hope it can recover as soon as the computer resumes from a standby mode.

In standby mode, I think all programs and connections would go to sleep and also the heart-beat detection mechanism.

I want to know if there are some parameters (e.g. mina parameters, java vm parameters, or os parameters), which calculate the time limit of the connection becoming invalid.

Regards,

Li



> Subject: RE: About the time limit of connection keeps valid from 
> standby mode
> Date: Thu, 11 Sep 2008 13:50:05 +0800
> From: wenrui.guo@ericsson.com
> To: users@mina.apache.org
>
> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>
> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>
> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>
> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>
> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>
> Best Regards
> Anderson Guo
>

_________________________________________________________________
��Ů�԰�ӥ�`����Ԓ�}����լȼ��ϵ�������������Ĥʤ��Ӥ�򥲥åȣ�
http://clk.atdmt.com/GBL/go/112813569/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by li <cu...@live.jp>.
Hi, Anderson Guo,

Thanks for your reply.

As you guess, my connection is a long-term connection and I hope it can recover as soon as the computer resumes from a standby mode.

In standby mode, I think all programs and connections would go to sleep and also the heart-beat detection mechanism.

I want to know if there are some parameters (e.g. mina parameters, java vm parameters, or os parameters), which calculate the time limit of the connection becoming invalid.

Regards,

Li



> Subject: RE: About the time limit of connection keeps valid from standby mode
> Date: Thu, 11 Sep 2008 13:50:05 +0800
> From: wenrui.guo@ericsson.com
> To: users@mina.apache.org
>
> I am not sure if I understand your issue, but I would like to share my opinion with you about it:
>
> First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).
>
> Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.
>
> Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.
>
> BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.
>
> Best Regards
> Anderson Guo
>

_________________________________________________________________
【女性版ビリー?】話題の自宅燃焼系!美しく健康的なくびれをゲット!
http://clk.atdmt.com/GBL/go/112813569/direct/01/

RE: About the time limit of connection keeps valid from standby mode

Posted by Wenrui Guo <we...@ericsson.com>.
I am not sure if I understand your issue, but I would like to share my opinion with you about it:

First of all, Mina is suitable for both long-term and short-term connection oriented programming. Long-term connections means lifetime of the connection will last from begin to end, usually the communication protocol should has operations that responsible for session create, session keepalive, session close. On the other hand, short-term connections, just like http connections, created before http request is issued, till received corresponding http response. (But for the purpose of performance, most programmer choose to open keep-alive option to maintain the http connection between client and server).

Second, network related exceptions really exists during the communication phase, no matter what kind of connection manner you adoptm, so MINA provides exception listener method to allow programmers to process exception condition and recovery from it. Limited-retry , forget and continue are most popular approaches to handle such cases.

Finally, MINA is java-based network programming framework in nature, there is no way to know whether computer system is waken up from sleep mode. So I suggest the method to deal with connection invalid case is just encapsulate your source code to detect network io exceptions and try to resend your information again.

BTW, you mentioned that you connection maybe last for about 10 minutes, therefore I guess that program written by you is towards long-term connection, so please also adopt heart-beat detection mechanism inside you software.

Best Regards
Anderson Guo

-----Original Message-----
From: Allen Jiang [mailto:allenj@hz.webex.com] 
Sent: Thursday, September 11, 2008 1:17 PM
To: users@mina.apache.org
Subject: Re: About the time limit of connection keeps valid from standby mode

Hi,�� ����,
   Maybe you could check whether you have set the session to be closed when the session's idle event is activated in your server  site.

Yahoo ID:allen_jiangguilong 

----- Original Message -----
From: "�� ����" <cu...@live.jp>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 9:48 AM
Subject: About the time limit of connection keeps valid from standby mode


> 
> Hi,
> I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
> My test case is like this:
> OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2
> Mina version:2.0.0-M1
> Step:
> 1)My client program creates a connection to a server by using SocketConnector.
> 2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
> 3)Bring the computer out of standby mode after a time.
> I found the connection would be valid or invalid, according to the standby time.
> If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
> Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
> java.io.IOException: An existing connection was forcibly closed by the remote host.
> 
> I want to learn:
> 1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
> 2)Could I set this time limit?
> 
> Thanks,
> Li
> 
> _________________________________________________________________
> �ﱾ�����B�ݤ�������Τ�����ߤ�ʤΥ��������Lĩ���Ф�����å����褦
> http://clk.atdmt.com/GBL/go/112813570/direct/01/

Re: About the time limit of connection keeps valid from standby mode

Posted by Allen Jiang <al...@hz.webex.com>.
Hi,李 翠竹,
   Maybe you could check whether you have set the session to be closed when the session's idle event is activated in your server  site.

Yahoo ID:allen_jiangguilong 

----- Original Message ----- 
From: "李 翠竹" <cu...@live.jp>
To: <us...@mina.apache.org>
Sent: Thursday, September 11, 2008 9:48 AM
Subject: About the time limit of connection keeps valid from standby mode


> 
> Hi,
> I found the mina connection sometimes keeps valid, but sometimes goes invalid after the computer resumes from standby mode. 
> My test case is like this:
> OS:Microsoft Windows XP,Professional,Version 2002,Service Pack 2
> Mina version:2.0.0-M1
> Step:
> 1)My client program creates a connection to a server by using SocketConnector.
> 2)The computer on which my client program runs enters standby mode and the active connections are disconnected.
> 3)Bring the computer out of standby mode after a time.
> I found the connection would be valid or invalid, according to the standby time.
> If standby time is less than a period time(about 10 minutes), the connection still keeps valid and can send /receive datas.
> Else, the connection goes invalid and gets the fllowing exception when it attempt to send datas.
> java.io.IOException: An existing connection was forcibly closed by the remote host.
> 
> I want to learn:
> 1)How to calculate the time limit (about 10 minutes in my case) after which the connection become invalid in windows standby mode?
> 2)Could I set this time limit?
> 
> Thanks,
> Li
> 
> _________________________________________________________________
> 秋本番!連休たくさんのこの秋、みんなのオススメ週末旅行をチェックしよう
> http://clk.atdmt.com/GBL/go/112813570/direct/01/