Windows

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • OnSessionClosed not always triggered

    5 answers - 1453 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hello,
    I am actually doing some crash test on my server to handle as many
    situations as possible.
    I have a problem in a failed socket .Connect
    I create a few sockets to .Connect them to some remote points. The
    Connect will excecute and fail because there is nothing listening on
    destination (this is wanted situation to test my auto re-connect
    feature).
    The failure to connect will trigger a SessionConnected event with
    Error 10061 followed by a SessionClosed.
    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?
    But may be it is the first SessionClosed that should never happend ?
    2006/03/17 18:29:39 !ConnectorSessionConnected Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed Connector_2 (AT) 127 (DOT) 0.0.1:5433 (0 No Error)
    2006/03/17 18:29:39 !ConnectorSessionConnected Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed Connector_3 (AT) 127 (DOT) 0.0.1:5434 (0 No Error)
    2006/03/17 18:29:52 !ConnectorSessionConnected Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:53 !ConnectorSessionConnected Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
  • No.1 | | 2060 bytes | |

    Hello Dod,

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect,

    This is the correct way to do it.

    but this new try will only produce a
    SessionConnected not followed by a SessionClosed

    Never had that situation. In al my automated programs I rely on
    SessionClosed which is always called. If you are absolutely sure can
    you try to make a simple project to demonstrate the behaviour ?

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Saturday, March 18, 2006, 14:01, Dod wrote:

    Hello,

    I am actually doing some crash test on my server to handle as many
    situations as possible.

    I have a problem in a failed socket .Connect

    I create a few sockets to .Connect them to some remote points. The
    .Connect will excecute and fail because there is nothing listening on
    destination (this is wanted situation to test my auto re-connect
    feature).

    The failure to connect will trigger a SessionConnected event with
    Error 10061 followed by a SessionClosed.

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    But may be it is the first SessionClosed that should never happend ?

    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (0 No Error)
    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (0 No Error)
    2006/03/17 18:29:52 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:53 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
  • No.2 | | 2245 bytes | |

    Hello Dod,

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    I examined the project that demonstrate the problem. The client you use
    is derived from TWSocketClient instead of TWSocket. If you change it to
    TWSocket the connect / closed works every time. TWSocketClient's
    SessionClose is normally handled by TWSocketServer, so that's the
    reason your SessionClose does not trigger.

    I'm not sure wy it is fired the first time. This make it confusing.

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Saturday, March 18, 2006, 14:01, Dod wrote:

    Hello,

    I am actually doing some crash test on my server to handle as many
    situations as possible.

    I have a problem in a failed socket .Connect

    I create a few sockets to .Connect them to some remote points. The
    .Connect will excecute and fail because there is nothing listening on
    destination (this is wanted situation to test my auto re-connect
    feature).

    The failure to connect will trigger a SessionConnected event with
    Error 10061 followed by a SessionClosed.

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    But may be it is the first SessionClosed that should never happend ?

    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (0 No Error)
    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (0 No Error)
    2006/03/17 18:29:52 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:53 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
  • No.3 | | 3006 bytes | |

    Hi Dod,

    Did some additional research. If you wants to use TWSocketClient instead
    of TWSocket to initiate a connection, then you have to set
    FSessionClosedFlag := False; in the SessionClosed event. If you do not
    then SessionClosed will not trigger a second time.

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Sunday, March 19, 2006, 19:03, Wilfried Mestdagh wrote:

    Hello Dod,

    >In the SessionClosed I start a Timer that will send a message 20
    >second later to retry a .Connect, but this new try will only produce a
    >SessionConnected not followed by a SessionClosed, any idea why ?


    I examined the project that demonstrate the problem. The client you use
    is derived from TWSocketClient instead of TWSocket. If you change it to
    TWSocket the connect / closed works every time. TWSocketClient's
    SessionClose is normally handled by TWSocketServer, so that's the
    reason your SessionClose does not trigger.

    I'm not sure wy it is fired the first time. This make it confusing.

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Saturday, March 18, 2006, 14:01, Dod wrote:

    >Hello,


    >I am actually doing some crash test on my server to handle as many
    >situations as possible.


    >I have a problem in a failed socket .Connect


    >I create a few sockets to .Connect them to some remote points. The
    >.Connect will excecute and fail because there is nothing listening on
    >destination (this is wanted situation to test my auto re-connect
    >feature).


    >The failure to connect will trigger a SessionConnected event with
    >Error 10061 followed by a SessionClosed.


    >In the SessionClosed I start a Timer that will send a message 20
    >second later to retry a .Connect, but this new try will only produce a
    >SessionConnected not followed by a SessionClosed, any idea why ?


    >But may be it is the first SessionClosed that should never happend ?


    >2006/03/17 18:29:39 !ConnectorSessionConnected
    >Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    >2006/03/17 18:29:39 !ConnectorSessionClosed
    >Connector_2 (AT) 127 (DOT) 0.0.1:5433 (0 No Error)
    >2006/03/17 18:29:39 !ConnectorSessionConnected
    >Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
    >2006/03/17 18:29:39 !ConnectorSessionClosed
    >Connector_3 (AT) 127 (DOT) 0.0.1:5434 (0 No Error)
    >2006/03/17 18:29:52 !ConnectorSessionConnected
    >Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    >2006/03/17 18:29:53 !ConnectorSessionConnected
    >Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
  • No.4 | | 3702 bytes | |

    Hello Wilfried,

    Yes, I came to same conclusion too when you told me it worked fine
    with TWSocket. Now I simply set FSessionClosedFlag:=False before
    calling .Connect again and all is fine. I also added some
    FConnectDidError:=ErrCode in SessionConnected so when
    SessionClosed is called I test SessionClosed's ErrCode and also
    FConnectDidError then if one of them <>0 then I set Timer to make new
    Connect some seconds later.

    But I am still looking how to add the reverse connected TWSocketClient
    into the main TWSocketServer client's list.

    Actually once reverse'd TWSocketClient is connected I set it same
    DataAvailable/DataSent as other standard TWSocketServer clients as
    only connection and disconnection have to be handled differently.

    Regards.

    WMDid some additional research. If you wants to use TWSocketClient instead
    WMof TWSocket to initiate a connection, then you have to set
    WMFSessionClosedFlag := False; in the SessionClosed event. If you do not
    WMthen SessionClosed will not trigger a second time.

    WM
    WMRgds, Wilfried [TeamICS]
    WM
    WMhttp://www.mestdagh.biz

    WMSunday, March 19, 2006, 19:03, Wilfried Mestdagh wrote:

    >Hello Dod,


    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    >I examined the project that demonstrate the problem. The client you use
    >is derived from TWSocketClient instead of TWSocket. If you change it to
    >TWSocket the connect / closed works every time. TWSocketClient's
    >SessionClose is normally handled by TWSocketServer, so that's the
    >reason your SessionClose does not trigger.


    >I'm not sure wy it is fired the first time. This make it confusing.


    >
    >Rgds, Wilfried [TeamICS]
    >
    >http://www.mestdagh.biz


    >Saturday, March 18, 2006, 14:01, Dod wrote:


    Hello,

    I am actually doing some crash test on my server to handle as many
    situations as possible.

    I have a problem in a failed socket .Connect

    I create a few sockets to .Connect them to some remote points. The
    .Connect will excecute and fail because there is nothing listening on
    destination (this is wanted situation to test my auto re-connect
    feature).

    The failure to connect will trigger a SessionConnected event with
    Error 10061 followed by a SessionClosed.

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    But may be it is the first SessionClosed that should never happend ?

    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (0 No Error)
    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (0 No Error)
    2006/03/17 18:29:52 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:53 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
  • No.5 | | 3805 bytes | |

    Hello Dod,

    I think you have to override the Notification method of
    TWSocketServer. I only did a quick look

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Sunday, March 19, 2006, 22:28, Dod wrote:

    Hello Wilfried,

    Yes, I came to same conclusion too when you told me it worked fine
    with TWSocket. Now I simply set FSessionClosedFlag:=False before
    calling .Connect again and all is fine. I also added some
    FConnectDidError:=ErrCode in SessionConnected so when
    SessionClosed is called I test SessionClosed's ErrCode and also
    FConnectDidError then if one of them <>0 then I set Timer to make new
    .Connect some seconds later.

    But I am still looking how to add the reverse connected TWSocketClient
    into the main TWSocketServer client's list.

    Actually once reverse'd TWSocketClient is connected I set it same
    DataAvailable/DataSent as other standard TWSocketServer clients as
    only connection and disconnection have to be handled differently.

    Regards.

    WM>Did some additional research. If you wants to use TWSocketClient instead
    WM>of TWSocket to initiate a connection, then you have to set
    WM>FSessionClosedFlag := False; in the SessionClosed event. If you do not
    WM>then SessionClosed will not trigger a second time.

    WM>
    WM>Rgds, Wilfried [TeamICS]
    WM>
    WM>http://www.mestdagh.biz

    WM>Sunday, March 19, 2006, 19:03, Wilfried Mestdagh wrote:

    Hello Dod,

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    I examined the project that demonstrate the problem. The client you use
    is derived from TWSocketClient instead of TWSocket. If you change it to
    TWSocket the connect / closed works every time. TWSocketClient's
    SessionClose is normally handled by TWSocketServer, so that's the
    reason your SessionClose does not trigger.

    I'm not sure wy it is fired the first time. This make it confusing.

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Saturday, March 18, 2006, 14:01, Dod wrote:

    Hello,

    I am actually doing some crash test on my server to handle as many
    situations as possible.

    I have a problem in a failed socket .Connect

    I create a few sockets to .Connect them to some remote points. The
    .Connect will excecute and fail because there is nothing listening on
    destination (this is wanted situation to test my auto re-connect
    feature).

    The failure to connect will trigger a SessionConnected event with
    Error 10061 followed by a SessionClosed.

    In the SessionClosed I start a Timer that will send a message 20
    second later to retry a .Connect, but this new try will only produce a
    SessionConnected not followed by a SessionClosed, any idea why ?

    But may be it is the first SessionClosed that should never happend ?

    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (0 No Error)
    2006/03/17 18:29:39 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)
    2006/03/17 18:29:39 !ConnectorSessionClosed
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (0 No Error)
    2006/03/17 18:29:52 !ConnectorSessionConnected
    Connector_2 (AT) 127 (DOT) 0.0.1:5433 (10061 Connection refused)
    2006/03/17 18:29:53 !ConnectorSessionConnected
    Connector_3 (AT) 127 (DOT) 0.0.1:5434 (10061 Connection refused)

Re: OnSessionClosed not always triggered


max 4000 letters.
Your nickname that display:
In order to stop the spam: 6 + 5 =
QUESTION ON "Windows"

EMSDN.COM