Print Page | Close Window

Notification service won't unsubscribe

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3268
Printed Date: 24-Apr-2024 at 2:07am


Topic: Notification service won't unsubscribe
Posted By: pponzano
Subject: Notification service won't unsubscribe
Date Posted: 16-Feb-2012 at 7:08am
Hello,
I've started looking with fiddler the traffic I've with my WPF application... I've noticed then when I close the application but don't stop the server (what it normally should be in a real production server) I have the NotificationService that continues to send message even if I've called the  Manager.CancelCallback...

my code is :

Repository :

public void RegisterCallBack(string serviceTypeName, string serviceMethodName, Action<SubscriptionOperation> callback, object userToken, params object[] clientArgs)

   {

       try

       {

           Manager.RegisterCallback(serviceTypeName, serviceMethodName, callback, userToken, clientArgs);

       }

       catch (Exception ex)

       {

           //todo : add logging

       }

   }

 

   public void CancelCallBack(object userToken)

   {

       try

       {

           Manager.CancelCallback(userToken);

       }

       catch (Exception ex)

       {

           //todo : add logging

       }

   }


(no exception are thrown BTW)

on the BootStrapper :

     protected override void OnExit(object sender, EventArgs e)
        {
            base.OnExit(sender, e);

            if (repository != null)
            {
                repository.CancelCallBack(UserMessagesViewModel.NOTIFICATION_TOKEN);
            }

        }

In my UserMessageViewModel I subcribe as

private void SubscribeNotification()

    {

 

        if (isSubscribed)

        {

            repository.CancelCallBack(NOTIFICATION_TOKEN);

        }

 

        var objArray = new object[] { repository.GetLoggedUser(), FilterAncheVisti };

 

        repository.RegisterCallBack(NOTIFICATION_SERVICE_PATH, NOTIFICATION_SERVICE_METHOD, UserMessagePushCallback, NOTIFICATION_TOKEN, objArray);

 

        isSubscribed = true;

 

    }


What can I do wrong?





Replies:
Posted By: sbelini
Date Posted: 16-Feb-2012 at 4:39pm
Hi Paolo,
 
I was not able to reproduce the issue here.
I have tested using DevForce 6.1.5.1. What version of DevForce are you using?
 
I did some testing with our WPF Push Notification sample and here's the outcome:
 
Once a client calls CancelCallback, the server should register in its DebugLog:
IdeaBlade.EntityModel.Server.NotificationServiceManager:UnregisterUser - User unregistered from _Service Name_
 
Once all clients subscribing to the notification service unsubscribe to it, the server will stop the notification service:
IdeaBlade.EntityModel.Server.NotificationThreadHelper:StopThread - Stopping thread for _Service Name_
IdeaBlade.EntityModel.Server.NotificationServiceManager:NotificationThreadCompleted - Server method completed: _Service Name_
I also verified that if the user closes the client app without unsubscribing to the service, the server will eventually remove the subscriber after a timeout: (1 min default)
IdeaBlade.EntityModel.Server.NotificationServiceManager:AsyncNotify - Removing subscriber after error The message could not be transferred within the allotted timeout of 00:01:00. There was no space available in the reliable channel's transfer window. The time allotted to this operation may have been a portion of a longer timeout.
 
 
As for not unsubscribing upon calling CancelCallback, it can only think of not having the right token. Could you verify that the token is accurate?
Also, could you ensure there are no other subscribers to the notification service? (notificationManager.GetSubscribers(serviceKey).Count())
 
Regards,
   Silvio.


Posted By: pponzano
Date Posted: 16-Feb-2012 at 11:30pm
Hello Silvio..... I've not found the DevForce 6.1.5.1 from the avaiable downloads.. where can I download it?
I'll check the logs and the GetSubScribers(....)
Let you know thanks


Posted By: sbelini
Date Posted: 17-Feb-2012 at 10:56am
Paolo,
DevForce 6.1.5.1 is the latest varsion availble. You will be able to download it in our http://www.ideablade.com/download-portal - Customer Portal .
 
Silvio.


Posted By: mitchell_bu
Date Posted: 23-Feb-2012 at 7:37am
pponzano, did upgrading to 6.1.5.1 fix your problem?  I have a Silerlight application with 6.1.4.0 and am having a similar issue.  It only surfaced when using the Silverlight 5 runtime.  When the application is closed, the notification service subscription remains active even though we explicitly unsubscribe in the Application.Exit event.  This results in the browser process (IE, firefox,etc) to never release its resources.


Posted By: pponzano
Date Posted: 23-Feb-2012 at 8:01am
Hello mitchel_bu, I've not upgraded to .5.1 but I've noticed that the subscribe is removed when I close the client, and there're one,two times (I think it's due to the fact it takes a little time to unsubscribe), I'll test in next days and let you know


Posted By: mitchell_bu
Date Posted: 22-Mar-2012 at 2:07pm
This seems to be a issue that refuses to die for us...
 
We upgraded to 6.1.6.0 and it fixed our initial issue.  It seemed that originally, when the browser was closed, the client was still holding onto a reference to the subscription, which wasn't allowing the process to release it's resources.  DevForce acknowledged this was a bug (Fixed a problem where the browser process would not terminate if a Silverlight application had an outstanding subscription to a Push service. [D1987]) and fixed it for 6.1.6.0.
 
However, even though the browser process now terminates, the service appears to never be notified that the client has closed and continues to run.  This is problematic for us because the service assumes the information it sends is being received and updates the database that the data has been sent to the client.  We could rearrange the code and have the client update the DB once it receives the notification, but I feel this is just putting on a bandaid as we will still have multiple instances of the service running, and will continue to run after the client closes.
 
I have tried handling the Application.Exit event and adding code to unsubscribe from all existing subscriptions just like pponzano, but haven't had any luck in it actually working.



Print Page | Close Window