Legacy Dev Forum Posts

 View Only

Sign Up

NotificationHandler C# stops sending notification

  • 1.  NotificationHandler C# stops sending notification

    Posted 06-05-2025 18:06

    Michael.Shrall | 2020-03-17 04:07:54 UTC | #1

    I am noticing an issue with NotificationHandler where the notifications stop being delivered after numerous NotificationHandlers have been created with numerous topics. Any guidance on how to research or debug to figure out what is happening? I have confirmed the class is not being nulled out, the RemoveSubscription is not being called and the event handler is not being removed.

    After restarting the app, it works again for a little bit and then notifications stop coming through.


    tim.smith | 2020-03-17 14:35:23 UTC | #2

    Are you still receiving heartbeats and events on the websocket? You can access the WebSocket object directly and set a handler for the raw events from it.


    Michael.Shrall | 2020-03-17 15:34:18 UTC | #3

    After further investigation I found that if I contained the NotificationHandler in one of my classes and created numerous of those classes that it didn't like numerous instance created of that object. At one point I hit the API Throttles for notification channels. As such I moved to a static NotificationHandler across all instances of the object and now seeing it work properly. It appears just creating a new instance of the NotificationHandler is initializing new channels/sockets which may be limiting.

    Any best practice guidance on usage of NotificationHandler and subscriptions when you are monitoring users/queues?


    tim.smith | 2020-03-17 15:41:39 UTC | #4

    The behavior you're describing is expected. If you're creating a new instance of NotificationHandler using the default constructor repeatedly, it's going to create a new channel each time and you'll invalidate the old channels as you exceed the channel limit. I'd recommend using a single instance of the object in your application.

    It is possible to create multiple instances of NotificationHandler for the same channel, though your use case isn't really what that's for. When creating new instances, you'll have to provide the Channel from the previous instance to prevent it from creating a new one. You will also have to call AddSubscriptions to re-register topics in each instance since the association between a topic and the event classes you register are maintained within the individual NotificationHandler instance.


    system | 2020-04-17 15:41:40 UTC | #5

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 7360