Skip to main content


Hello,


In our migration from another provider to RingCentral SMS, we increased the flow of SMS traffic though our RingCentral A2P 10DLC number in the last 24 hours.

When we did so we started seeing an increase in error 401's in our batch calls. Additionally, we are seeing an increase in delivery error 429 on your RingCentral server (especially when our traffic is at its peak).

We had to take the action of decreasing the traffic we are sending to your server (moving back to the previous provider) until we determine how to best resolve this.


We are using the Java implementation. I note that we are not keeping the session open and furthermore, we are not batching the sends (1 message per batch). It is implemented this way following your code example AND migrating from another provider's basic flow of control that we use.

Please see an example of the error 401 below.


Please advise, are we hitting a bug in your service or are we misusing the API ?



2020-11-23 13:43:45,855 [error] Thread-541640 MessagingServiceImpl:64 RingCentral exception - com.envera.east.sms.notification.service.MessagingException: HTTP Response

=============

status code: 401


Server: nginx

Date: Mon, 23 Nov 2020 18:43:45 GMT

Content-Type: application/json

Content-Length: 175

Connection: keep-alive

WWW-Authenticate: Bearer realm="RingCentral REST API"

RCRequestId: d158ffb4-2dbb-11eb-860b-0050568dac6b


{

"errorCode" : "AGW-402",

"message" : "Invalid Authorization header",

"errors" : [ {

"errorCode" : "AGW-402",

"message" : "Invalid Authorization header"

} ]

}


HTTP Request

============

HTTP POST https://platform.ringcentral.com/restapi/v1.0/account/~/a2p-sms/batch


Authorization: Basic <Note: I deleted our token>

X-User-Agent: RC-JAVA-SDK Java 1.8.0_102 Windows Server 2012 R2


{"from":"19412634395"," <...deleted detail...>

Hi Bob, what is your email address? I am happy to jump on a call and assist you better.


bmulvey@enverasystems.com


I cannot send a Team messaging invite to this email address. Is your IT block this feature?


I also don't understand your problem. You showed the authentication error below, which seemed you could not pass the authentication (login). How could you call the a2p/batch to send SMS?

{
"errorCode" : "AGW-402",
"message" : "Invalid Authorization header",
"errors" : [ {
"errorCode" : "AGW-402",
"message" : "Invalid Authorization header"
} ]
}

And where is the 401 and 429 errors?



There are 2 problems here, not 1. that is why. The problems both increase as I increase flow rate from the old provider to new.


Just thought I would give an update for the community. Phong helped me!

The issue for us was that we were being VERY inefficient in our implementation. We were re-authenticating for every send. At the rates we are sending this is not good. We did this simply because the prior implementation we had sort-of took us down that path (but that prior implementation was P2P using multiple numbers).

Instead, we will now use "restClient.autoRefresh()" in our java implementation's singleton that instantiates the RingCentral RestClient object.

At that point, we should be good to go. I will say though I wish there was a way for us to check to see if we were authenticated. I write this because in the case of misc error handling, I'd like to validate the authentication (just in cases it is somehow lost). If I was able to do this, it would allow me, in my error handling, to get a new token.


Hi Bob,

To check if the app is authenticated, you can rely on the token object from the restClient instance. Once you call the authorize(), the token object will have token info, otherwise, it is null. However, there is no guarantee that if the access token and the refresh token are still valid. If you turn on the auto refresh, you'll just rely on the SDK to use the refresh token to refresh and keep the access token valid while your singleton process is running. If something goes wrong with the auto refresh so the SDK cannot refresh the token, you will catch this error when trying to call an API "Auth exception: Refresh token has expired". So always wrap your API call around a try{} catch(){}

public class RestClient {
public static final String SANDBOX_SERVER = "https://platform.devtest.ringcentral.com";
public static final String PRODUCTION_SERVER = "https://platform.ringcentral.com";
...
public TokenInfo token;



Reply