Comet implementation

Discussion in 'ASP .Net Web Services' started by Jonny Bergdahl, Jan 20, 2009.

  1. > So far based on my research, at server-side, WCF method can use
    > "OperationContext.Current" to inspect some WCF method invocation context
    > info. And the OperationContext class has a "InstanceContext" property that
    > can help inspect the current communication object's State:


    Sorry for the late reply, I haven't come around to this until now.

    I am sorry to report that this does not seem work. The
    OperationContext.Current.InstanceContext.State only seems to track the
    internal state of thre service object, and not the communication state.

    When I have initiated a connection from the client, State is set top Opened.
    But even after I have closed down the Client, it is still set to Opened even
    though the HTTP connection is closed.

    What I need is to keep track of the underlying HTTP connection state,
    something like HttpResponse.IsClientConnected.

    Any other ideas on how to get to the underlying connection?

    Regards;
    /jb
    Jonny Bergdahl, Jan 20, 2009
    #1
    1. Advertising

  2. Jonny Bergdahl

    Steven Cheng Guest

    Hi Jonny,

    Thanks for your followup.

    Also sorry for the late reponse as I was dealing with some other issues
    recently. Regarding on the detecting client-side disconnecting problem,
    I've also performed some further research. It seems for normal one-way
    binding(comparing to thte duplex binding), the client-side disconnect
    detection is not real-time. Here are some web articles discussing on this
    issue:

    #WCF Notification on Disconnect
    http://www.rcs-solutions.com/blog/2008/07/06/WCFNotificationOnDisconnect.asp
    x

    #Taking Action on Client Close
    http://blogs.msdn.com/drnick/archive/2008/01/07/taking-action-on-client-clos
    e.aspx

    #Provide Way to Detect Client Abort/Disconnect in WCF
    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/7fb25e30-fc74-4a52-
    9dfd-232c67c84f7a

    I've tried registering some eventhandler on the OperationContext's Channel,
    but those event won't be raised until the service method return data to
    client-side. e.g,

    ========================
    public string GetData(string user)
    {
    Console.WriteLine("GetData Begin:{0}", DateTime.Now);


    OperationContext oc = OperationContext.Current;


    oc.Channel.Closed += new EventHandler(Channel_Closed);
    oc.Channel.Closing += new EventHandler(Channel_Closing);
    oc.Channel.Faulted += new EventHandler(Channel_Faulted);


    for (int i = 0; i < 10; ++i)
    {
    Console.WriteLine("Loop:{0}, State:{1}",i,
    oc.Channel.State);


    Thread.Sleep(1000 * 3);
    }


    Console.WriteLine("GetData End:{0}", DateTime.Now);

    return "result of " + user;

    }
    ===============================

    If duplex binding is possible for your scenario, you may have a try on the
    solution mentioned in above articles.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.


    --------------------
    >From: "Jonny Bergdahl" <>
    >Subject: Comet implementation
    >Date: Tue, 20 Jan 2009 16:43:19 +0100


    >
    >> So far based on my research, at server-side, WCF method can use
    >> "OperationContext.Current" to inspect some WCF method invocation context
    >> info. And the OperationContext class has a "InstanceContext" property

    that
    >> can help inspect the current communication object's State:

    >
    >Sorry for the late reply, I haven't come around to this until now.
    >
    >I am sorry to report that this does not seem work. The
    >OperationContext.Current.InstanceContext.State only seems to track the
    >internal state of thre service object, and not the communication state.
    >
    >When I have initiated a connection from the client, State is set top

    Opened.
    >But even after I have closed down the Client, it is still set to Opened

    even
    >though the HTTP connection is closed.
    >
    >What I need is to keep track of the underlying HTTP connection state,
    >something like HttpResponse.IsClientConnected.
    >
    >Any other ideas on how to get to the underlying connection?
    >
    >Regards;
    >/jb
    >
    >
    Steven Cheng, Jan 21, 2009
    #2
    1. Advertising

  3. Unfortunately, the web service is consumed over the internet, so there is no
    way to initiate a callback to the client.

    Regards;
    /jb

    ""Steven Cheng"" <> skrev i meddelandet
    news:...
    > Hi Jonny,
    >
    > Thanks for your followup.
    >
    > Also sorry for the late reponse as I was dealing with some other issues
    > recently. Regarding on the detecting client-side disconnecting problem,
    > I've also performed some further research. It seems for normal one-way
    > binding(comparing to thte duplex binding), the client-side disconnect
    > detection is not real-time. Here are some web articles discussing on this
    > issue:
    >
    > #WCF Notification on Disconnect
    > http://www.rcs-solutions.com/blog/2008/07/06/WCFNotificationOnDisconnect.asp
    > x
    >
    > #Taking Action on Client Close
    > http://blogs.msdn.com/drnick/archive/2008/01/07/taking-action-on-client-clos
    > e.aspx
    >
    > #Provide Way to Detect Client Abort/Disconnect in WCF
    > http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/7fb25e30-fc74-4a52-
    > 9dfd-232c67c84f7a
    >
    > I've tried registering some eventhandler on the OperationContext's
    > Channel,
    > but those event won't be raised until the service method return data to
    > client-side. e.g,
    >
    > ========================
    > public string GetData(string user)
    > {
    > Console.WriteLine("GetData Begin:{0}", DateTime.Now);
    >
    >
    > OperationContext oc = OperationContext.Current;
    >
    >
    > oc.Channel.Closed += new EventHandler(Channel_Closed);
    > oc.Channel.Closing += new EventHandler(Channel_Closing);
    > oc.Channel.Faulted += new EventHandler(Channel_Faulted);
    >
    >
    > for (int i = 0; i < 10; ++i)
    > {
    > Console.WriteLine("Loop:{0}, State:{1}",i,
    > oc.Channel.State);
    >
    >
    > Thread.Sleep(1000 * 3);
    > }
    >
    >
    > Console.WriteLine("GetData End:{0}", DateTime.Now);
    >
    > return "result of " + user;
    >
    > }
    > ===============================
    >
    > If duplex binding is possible for your scenario, you may have a try on the
    > solution mentioned in above articles.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    >
    > --------------------
    >>From: "Jonny Bergdahl" <>
    >>Subject: Comet implementation
    >>Date: Tue, 20 Jan 2009 16:43:19 +0100

    >
    >>
    >>> So far based on my research, at server-side, WCF method can use
    >>> "OperationContext.Current" to inspect some WCF method invocation context
    >>> info. And the OperationContext class has a "InstanceContext" property

    > that
    >>> can help inspect the current communication object's State:

    >>
    >>Sorry for the late reply, I haven't come around to this until now.
    >>
    >>I am sorry to report that this does not seem work. The
    >>OperationContext.Current.InstanceContext.State only seems to track the
    >>internal state of thre service object, and not the communication state.
    >>
    >>When I have initiated a connection from the client, State is set top

    > Opened.
    >>But even after I have closed down the Client, it is still set to Opened

    > even
    >>though the HTTP connection is closed.
    >>
    >>What I need is to keep track of the underlying HTTP connection state,
    >>something like HttpResponse.IsClientConnected.
    >>
    >>Any other ideas on how to get to the underlying connection?
    >>
    >>Regards;
    >>/jb
    >>
    >>

    >
    Jonny Bergdahl, Jan 23, 2009
    #3
  4. Jonny Bergdahl

    msdngroup Guest

    See this site:

    HTTP server push

    http://www.udaparts.com/document/Tutorial/httppush.htm



    "Jonny Bergdahl" <> wrote in message
    news:...
    >> So far based on my research, at server-side, WCF method can use
    >> "OperationContext.Current" to inspect some WCF method invocation context
    >> info. And the OperationContext class has a "InstanceContext" property
    >> that
    >> can help inspect the current communication object's State:

    >
    > Sorry for the late reply, I haven't come around to this until now.
    >
    > I am sorry to report that this does not seem work. The
    > OperationContext.Current.InstanceContext.State only seems to track the
    > internal state of thre service object, and not the communication state.
    >
    > When I have initiated a connection from the client, State is set top
    > Opened.
    > But even after I have closed down the Client, it is still set to Opened
    > even
    > though the HTTP connection is closed.
    >
    > What I need is to keep track of the underlying HTTP connection state,
    > something like HttpResponse.IsClientConnected.
    >
    > Any other ideas on how to get to the underlying connection?
    >
    > Regards;
    > /jb
    >
    msdngroup, Jan 29, 2009
    #4
  5. Jonny Bergdahl

    Steven Cheng Guest

    I've performed some further research. Seems normal request/response channel
    cannot provide real-time detection on client-side disconnect. If you need
    to have a reliable way for detecting, client-side must also expose an
    endpoint that can be queried by the server-side.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    >From: "Jonny Bergdahl" <>
    >References: <>

    <>
    >In-Reply-To: <>
    >Subject: Re: Comet implementation
    >Date: Fri, 23 Jan 2009 15:53:03 +0100


    >
    >Unfortunately, the web service is consumed over the internet, so there is

    no
    >way to initiate a callback to the client.
    >
    >Regards;
    >/jb
    >
    >""Steven Cheng"" <> skrev i meddelandet
    >news:...
    >> Hi Jonny,
    >>
    >> Thanks for your followup.
    >>
    >> Also sorry for the late reponse as I was dealing with some other issues
    >> recently. Regarding on the detecting client-side disconnecting problem,
    >> I've also performed some further research. It seems for normal one-way
    >> binding(comparing to thte duplex binding), the client-side disconnect
    >> detection is not real-time. Here are some web articles discussing on this
    >> issue:
    >>
    >> #WCF Notification on Disconnect
    >>

    http://www.rcs-solutions.com/blog/2008/07/06/WCFNotificationOnDisconnect.asp
    >> x
    >>
    >> #Taking Action on Client Close
    >>

    http://blogs.msdn.com/drnick/archive/2008/01/07/taking-action-on-client-clos
    >> e.aspx
    >>
    >> #Provide Way to Detect Client Abort/Disconnect in WCF
    >>

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/7fb25e30-fc74-4a52-
    >> 9dfd-232c67c84f7a
    >>
    >> I've tried registering some eventhandler on the OperationContext's
    >> Channel,
    >> but those event won't be raised until the service method return data to
    >> client-side. e.g,
    >>
    >> ========================
    >> public string GetData(string user)
    >> {
    >> Console.WriteLine("GetData Begin:{0}", DateTime.Now);
    >>
    >>
    >> OperationContext oc = OperationContext.Current;
    >>
    >>
    >> oc.Channel.Closed += new EventHandler(Channel_Closed);
    >> oc.Channel.Closing += new EventHandler(Channel_Closing);
    >> oc.Channel.Faulted += new EventHandler(Channel_Faulted);
    >>
    >>
    >> for (int i = 0; i < 10; ++i)
    >> {
    >> Console.WriteLine("Loop:{0}, State:{1}",i,
    >> oc.Channel.State);
    >>
    >>
    >> Thread.Sleep(1000 * 3);
    >> }
    >>
    >>
    >> Console.WriteLine("GetData End:{0}", DateTime.Now);
    >>
    >> return "result of " + user;
    >>
    >> }
    >> ===============================
    >>
    >> If duplex binding is possible for your scenario, you may have a try on

    the
    >> solution mentioned in above articles.
    >>
    >> Sincerely,
    >>
    >> Steven Cheng
    >>
    >> Microsoft MSDN Online Support Lead
    >>
    >>
    >> Delighting our customers is our #1 priority. We welcome your comments and
    >> suggestions about how we can improve the support we provide to you.

    Please
    >> feel free to let my manager know what you think of the level of service
    >> provided. You can send feedback directly to my manager at:
    >> .
    >>
    >> ==================================================
    >> Get notification to my posts through email? Please refer to
    >>

    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >>
    >>
    >> --------------------
    >>>From: "Jonny Bergdahl" <>
    >>>Subject: Comet implementation
    >>>Date: Tue, 20 Jan 2009 16:43:19 +0100

    >>
    >>>
    >>>> So far based on my research, at server-side, WCF method can use
    >>>> "OperationContext.Current" to inspect some WCF method invocation

    context
    >>>> info. And the OperationContext class has a "InstanceContext" property

    >> that
    >>>> can help inspect the current communication object's State:
    >>>
    >>>Sorry for the late reply, I haven't come around to this until now.
    >>>
    >>>I am sorry to report that this does not seem work. The
    >>>OperationContext.Current.InstanceContext.State only seems to track the
    >>>internal state of thre service object, and not the communication state.
    >>>
    >>>When I have initiated a connection from the client, State is set top

    >> Opened.
    >>>But even after I have closed down the Client, it is still set to Opened

    >> even
    >>>though the HTTP connection is closed.
    >>>
    >>>What I need is to keep track of the underlying HTTP connection state,
    >>>something like HttpResponse.IsClientConnected.
    >>>
    >>>Any other ideas on how to get to the underlying connection?
    >>>
    >>>Regards;
    >>>/jb
    >>>
    >>>

    >>

    >
    >
    Steven Cheng, Feb 2, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr

    server pushed events and asp.net? (ie comet)

    Mad Scientist Jr, Oct 15, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    465
    Sahil Malik [MVP C#]
    Oct 15, 2006
  2. tony
    Replies:
    3
    Views:
    511
    Roedy Green
    Jun 29, 2007
  3. lightning

    tomcat comet server deploy?

    lightning, Feb 18, 2008, in forum: Java
    Replies:
    1
    Views:
    611
    lightning
    Feb 19, 2008
  4. Jonny Bergdahl

    Comet implementation in WCF

    Jonny Bergdahl, Nov 19, 2008, in forum: ASP .Net Web Services
    Replies:
    8
    Views:
    1,024
    Steven Cheng
    Jan 21, 2009
  5. Is comet push?

    , Jun 30, 2006, in forum: Javascript
    Replies:
    0
    Views:
    91
Loading...

Share This Page