News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
How to keep the subscription alive so that it does not expire after 15 minutes ASP.NET NVC
Tags: sdk
Jun 4, 2019 at 6:44am   •   4 replies  •  0 likes
station 1 lurie

My subscription was written in the Startup.cs file (with a hangfire dll) because I'm sending a message to clinters (using SignalR).

My problem is that when it is over 15 minutes the subscription is deleted.

I can run a timer every 14 minutes that will be re-subscribe or every 2 minutes to do renew.


What is the way to keep it always available?

4 Answers
answered on Aug 1, 2019 at 10:42am  

It is hard to say why the subscription is lost w/o knowing how the entire app is implemented and run.

However, if you expect the subscription to run for long hours or days, Webhooks notification is a better choice. Please read this article and consider it.


 0
answered on Aug 1, 2019 at 5:35am  

Hi, I implementation the subscription according to RingCentral.Net.Pubnub.Subscription I also run a timer every 55 minutes to keep alive token.

My problem is after a few hours the token continued to refresh but the subscription lost.

I logged token and subscription state every 55 minutes ( when refreshing token)

1) log token state before refreshing.

refreshing token...

2) log subscription mode after refresh token.

3) log token state after refreshing.


The log file log_2019-08-01 - Copy.txt

My code is

 public void Init()
        {
            AsyncContext.Run(async () =>
            {
                _rc = await _rcEngine.GetRestClient();
            });

            Timer aTimer = new Timer();
            aTimer.Elapsed += OnTimedEvent;
            aTimer.Interval = 1000 * 60 * 55;
            //aTimer.Interval = 1000 * 20 * 1;
            aTimer.Enabled = true;
        }

        private void OnTimedEvent(object sender, ElapsedEventArgs e)
        {
            _logger.Info($"token: {_rc.token?.access_token} expires_in:{_rc.token?.expires_in}");
            
            AsyncContext.Run(async () =>
            {
                await _rc.Refresh();

                var subscriptions = await _rc.Restapi().Subscription().List();

                if (subscriptions.records.Any())
                {
                    foreach (var subscriptionsRecord in subscriptions.records)
                    {
                        _logger.Info($"eventFilters: {String.Join(", ",subscriptionsRecord.eventFilters)} " +
                                     $"expirationTime:{subscriptionsRecord.expirationTime} " +
                                     $"expiresIn:{subscriptionsRecord.expiresIn}");
                    }
                }
            });

            _logger.Info($"token: {_rc.token?.access_token} expires_in:{_rc.token?.expires_in}");
        }

 0
answered on Jun 4, 2019 at 8:46am  

Thank you

I use Nuget Ringcentral.Net Pubnub to subscribe.

So how long did the Token stay alive and how to keep it alive?

I know the token stayed for an hour.


 0
answered on Jun 4, 2019 at 7:23am  

If you use the RingCentral .Net SDK to subscribe for notification, the subscription will be refreshed automatically as long as the access token (from the RestClient) is valid. If you don't use the RingCentral SDK, you have to implement a timer check the expiration time and call renew before it expires. See the code how it is handled by the SDK.


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us