question

z-admin avatar image
z-admin asked ·

SMS Subscription is not working after couple of hours

we are using the windows service to create the subscription and this windows service will be running always in the server, after couple of hours or more than those hours the subscription is not working and we have to start and stop the windows service to start the sending the SMS again.

do we need to do this always? do we have any mechanism to continuously keep running the service and sending the SMS all times.
topic-default
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

John Wang avatar image
John Wang answered ·
RingCentral access tokens and refresh tokens have expiration times associated with them. By default, access tokens expire in 1 hour and refresh tokens expire in 1 week. This means after 1 hour, your app will need to refresh the access token using the refresh token. If your app is not performing token refresh, it may stop being authorized after 1 hour.

Official RingCentral SDKs will perform auto-refresh if your app continues to make API calls. The new C# Client SDK will also auto renew as long as your service is running.

Are you using a SDK and, if so, which one? If not, what language are you using? Our SDKs are listed here:

https://developers.ringcentral.com/library/sdks.html

More information on OAuth token refresh is available on this here:

https://developers.ringcentral.com/api-docs/latest/index.html#!#OauthTokens.html
Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

z-admin avatar image
z-admin answered ·
Hello Team,

Apologies for the late reply on this thread.  We are using c# SDK for subscribing for incoming sms event . The subscription works as long as the incoming smses are being received . If there is no sms received for some time let's say an hour and later a new sms is received there is no notification coming. Once we restart the service it starts working again. Can you please help as we were assuming that in sdk we don't need to refresh.

2 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Can you indicate the C# SDK you are using via the GitHub URL or Nuget package? There are several so it would be good to know which one you are using.
0 Likes 0 · ·
RingCentralSDK.1.0.1
0 Likes 0 · ·
z-admin avatar image
z-admin answered ·
We are using the below code
 


private SDK sdk;        private SubscriptionService subscription;

        public void SetupSub()
        {
           
          
            Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "SetupSub", "*********************************Function Started*************************");
            string appsecret = ConfigurationManager.AppSettings["appsecret"];
            string appkey = ConfigurationManager.AppSettings["appkey"];
            string userphonenumber = ConfigurationManager.AppSettings["userphonenumber"];
            string password = ConfigurationManager.AppSettings["password"];
            string defaultendpoint = ConfigurationManager.AppSettings["apiendpoint"];
            string fromnumber = ConfigurationManager.AppSettings["fromnumber"];

            sdk = new SDK(appkey,appsecret, defaultendpoint, "IncomingSMSapp", "1.0.0");
            sdk.Platform.Login(userphonenumber, "", password, true);
            Logger.TraceLog(System.Diagnostics.TraceEventType.Information,"Info", "Subscription successful");
            subscription = sdk.CreateSubscription();

            subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS");
            var connectCount = 0;
            subscription.ConnectEvent += (sender, args) => {
                connectCount += 1;
               // Console.WriteLine(args.Message);
                Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Connected");
            };
            var messageCount = 0;
            subscription.NotificationEvent += (sender, args) => {
                messageCount += 1;
               // Console.WriteLine(args.Message);
                Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Incoming SMS  Notification received," + args.Message.ToString());

                var obj = JObject.Parse(args.Message.ToString());
              string messagecontent= obj.AsJEnumerable()["body"]["subject"].ToString();
              messagecontent = messagecontent.Replace("#", "%23");
              Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Incoming SMS  Notification received, message" + messagecontent);
              string from=obj.AsJEnumerable()["body"]["from"]["phoneNumber"].ToString();
              Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Incoming SMS  Notification received, From" + from);
              string to = obj.AsJEnumerable()["body"]["to"][0].ToString().Split(':')[1].Split('"')[1];
              from = from.Remove(0, 1);
              Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Incoming SMS  Notification received, To" + to);
              Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Incoming SMS  Notification received, To" + from);
             
            };
            var errorCount = 0;
            subscription.ErrorEvent += (sender, args) => {
                errorCount += 1;
               // Console.WriteLine(args.Message);
                Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Incoming SMS  Error received," + args.Message);
            };
            subscription.Register();
            Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Subscribed successfully");
            
                Logger.TraceLog(System.Diagnostics.TraceEventType.Information, "Info", "Thread", "Waiting for incoming sms events");
            


4 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

That looks like:  https://github.com/ringcentral/ringcentral-csharp

Will pass to the SDK team.
0 Likes 0 · ·
do i need to use 1.0.2-alpha1 instead?
0 Likes 0 · ·
Hi Team Any updates?
0 Likes 0 · ·
It would seem that you've been working with Tyler in the Github repository/issue tracker for this here ( https://github.com/ringcentral/ringcentral-csharp/issues/61). So I am going to mark this conversation as Acknowledged.
0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.