Skip to main content

Hi community,


I have issue regarding using sip server in C# to answer the call that has been supervised by party and send to my device.

During the development phase we were using your RingCentral phone (windows) application, to automatically register device and answer the calls, that were supervised by party. During testing phase we notice that phone application is add calls on hold if there are simultaneous. So we develop and active SIP Server that will register our device and respond to the SIP messages.

Issue:

We successfully registering extension programmatically in code. After every call, we supervise by party and receive event “INVITE”, on which we are trying to respond with “TRYING” and “200OK (SDP)”, in order to answer the call and receive the RTP data. After send 200OK on the INVITE we receive this error:


"errorCode" : "TAS-119",

"message" : "Can't reach deviceId specified in request".


Our registered device is online after registration.

Can you provide me more information what we’re doing wrong or any suggestion how to continue. In attachments I have add the Wireshark trace from the network and the error description that we receive after super-vise by party.


Code flow:

- Making CreateSipRegistrationRequest

CreateSipRegistrationRequest createSipRegistrationRequest = new CreateSipRegistrationRequest
            {
                sipInfo = new ] { new SIPInfoRequest { transport = "TCP" }, },
                device = new DeviceInfoRequest()
                {
                    computerName = Environment.MachineName
                }
            };

            CreateSipRegistrationResponse response = Client.Restapi().ClientInfo().SipProvision().Post(createSipRegistrationRequest).Result;


- With received response (SipInfoResponse), we connect our TcpClient to the specif IP and port

- After successful connection from our TcpClient we send REGISTER sip message

- We are receiving TRYING and 401 Unauthorized with specific nonce,

- With that specific nonce from 401 message, we are creating authorization header and send REGISTER sip message again, on which we are receiving 200 OK.
- On this way we register our device.

After this we are trying to make test call, and supervise the call. On create call with RingCentral phone, we are receiving events for the call event, after answer the call from the other side, we try to super-vise the call.

We are supervising the call with specific code:


PartySuperviseRequest superviseCallSessionRequest = new PartySuperviseRequest
                        {
                            mode = LISTEN_MODE,
                            supervisorDeviceId = DeviceId,
                            agentExtensionId = !string.IsNullOrEmpty(message.ExtensionId) ? message.ExtensionId : !string.IsNullOrEmpty(message.FromExtension) ? message.FromExtension : message.ToExtension,
                        };
                        var account = Client.Restapi().Account().Get().Result;
                        var result = Client.Restapi().Account(account.id.ToString()).Telephony().Sessions(message.TelephoneSessionId).Parties(partyId).Supervise().Post(superviseCallSessionRequest).Result;


After this call, we receive sip INVITE on our extension set for supervise. We have the network in the wireshark trace bellow. On this INVITE we are trying to send 200 OK in order to answer the call. After sending this 200OK, we recive the specific error:


StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: keep-alive
  X-Rate-Limit-Group: light
  X-Rate-Limit-Limit: 50
  X-Rate-Limit-Remaining: 49
  X-Rate-Limit-Window: 60
  RoutingKey: SJC12P01
  RCRequestId: e0b62fec-386d-11eb-ba42-005056bb86e2
  Date: Mon, 07 Dec 2020 09:23:39 GMT
  Server: nginx
  Content-Length: 140
  Content-Type: application/json
}
Content: {
   "errors" :
      {
         "errorCode" : "TAS-119",
         "message" : "Can't reach deviceId specified in request"
      }
   ]
}


If we are doing the supervise with active RingCentral phone (windiows) application, it's working fine, because the answering of the call is done from the RingCentral Phone application. In order to support multiple simultaneous calls, we are trying to create active sip server.


I have Wireshark trace from the traffic during registration and answer of the call.


Wireshark Trace

https://drive.google.com/file/d/1Q0dVG6m-25gPNSVSpxWoRK_YgmMx0OUO/view?usp=sharing


Response from supervise by party

https://drive.google.com/file/d/1AlVtn3fwfoAOr3vIKOKpl7Dptyqc56H8/view?usp=sharing

Can you explain more about this part?

"During the development phase we were using your RingCentral phone (windows) application, to automatically register device and answer the calls, that were supervised by party. During testing phase we notice that phone application is add calls on hold if there are simultaneous. So we develop and active SIP Server that will register our device and respond to the SIP messages."


How did it "automatically register device and answer the calls"? What is "supervised by party"? Does the "add calls on hold ..." have anything to do with this? Did it work w/o putting a call on hold? And "active SIP server ..."


Hi Phong Vu,
Thanks for helping.

We are trying to implement RingCentral supervise by party in our current software, call recording solution. In the development we have used RingCentral.NET library (https://github.com/ringcentral/RingCentral.Net) and some of the documentation from the developer's guide. We are following particular this one https://developers.ringcentral.com/guide/voice/supervision.

We are trying to achieve recording by local side. How we started:
- created application with all permission in sandbox,
- used this application credentials to authorize (RestClient)
- subscribe for events ("/restapi/v1.0/account/~/telephony/sessions")
- on every answer event, we are trying to supervise by party with particular code:

Client.Restapi().Account(account.id.ToString()).Telephony().Sessions(message.TelephoneSessionId).Parties(partyId).Supervise().Post(superviseCallSessionRequest).Result

- After this api call, ringcentral is creating new sip call that is transfered to the extension and device we have been registered.

During development process we were using RingCentral phone to register our extension for supervision (https://www.ringcentral.com/apps/rc-phone), this I'm calling manual registration of the device. In this way when we have two calls at the same time, first call goes automatically on hold, and i'm not sure how to answer multiple calls and not to go on hold.

This is the reason we started to create active SIP server application, that will register with particular extension and will try to respond on SIP messages like (INVITE, BYE, CANCEL) with particular responses in order to ANSWER or HANG UP the call. I'm not sure if this way will allow us to answer multiple calls and not to go on hold.


It looks like you try to call the number which is in an active call rather than supervise that call.
--

During development process we were using RingCentral phone to register our extension for supervision (https://www.ringcentral.com/apps/rc-phone), this I'm calling manual registration of the device. In this way when we have two calls at the same time, first call goes automatically on hold, and i'm not sure how to answer multiple calls and not to go on hold.

--

I did not see you mention about the call monitoring group configuration at all. Did you do that and how. Read this blog to see how I explained about configuration and how to implement a real time call conversation which also covers the channel recording as well. Project source code is in Node JS but it should give you an idea of what to call and when.

Please let me know when you have more questions.


Thanks for the response. We are following same approach but in .NET Framework 4.5. Because we don't have implementation for Softphone, the one that is used in nodejs example, we are registering our sip device with this code.

CreateSipRegistrationRequest createSipRegistrationRequest = new CreateSipRegistrationRequest
            {
                sipInfo = new ] { new SIPInfoRequest { transport = "TCP" }, },
                device = new DeviceInfoRequest()
                {
                    computerName = Environment.MachineName
                }
            };

            CreateSipRegistrationResponse response = Client.Restapi().ClientInfo().SipProvision().Post(createSipRegistrationRequest).Result;

This API call is successful. That means we have registered our device to using TCP protocol with the current machine name. Once we do this we are going with the similar example.

1607620411048.png


Also we are follwing this example: https://medium.com/ringcentral-developers/how-to-programmatically-create-a-ringcentral-device-2281edd661ec , but instead of websocket we use TCP.

Also Instead of softphone in your example we are using TCP client from TcpClient class. When we doing supervise we also receive INVITE sip message to our TCP Client and we are trying to repond with 200 OK. On responding our supervise call throw exception with particular error:


StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: keep-alive
  X-Rate-Limit-Group: light
  X-Rate-Limit-Limit: 50
  X-Rate-Limit-Remaining: 49
  X-Rate-Limit-Window: 60
  RoutingKey: SJC12P01
  RCRequestId: e0b62fec-386d-11eb-ba42-005056bb86e2
  Date: Mon, 07 Dec 2020 09:23:39 GMT
  Server: nginx
  Content-Length: 140
  Content-Type: application/json
}
Content: {
   "errors" : p
      {
         "errorCode" : "TAS-119",
         "message" : "Can't reach deviceId specified in request"
      }
   ]
}

All the examples that we follow are from examples that are already working in NODEJS.

My question is, do we do something wrong on create 200 OK for the INVITE, because cannot see that error or error description anywhere on the community, either google or any place. We are stuck on this one in order to complete the project.

Sorry for the long conversion and thanks again for the effort.


Your call monitoring group looks strange, 301, 302, 303 and 304 are supervisors and they can supervise 302, 303, 304 and 305. So who supposes to supervise whom? Not sure yet if it causes some problem but the logic is wrong.

Now tell me who call whom and which extension logged in the app to supervise?



Extension 302 should supervise other extensions 301, 303, 304. This is initial test setup.
I have logged with:
Username: + 442035452175
Extension: 302
Password: (extension password)
Url: https://platform.devtest.ringcentral.com


Client id and client secret from application credentials.


Additional logs regarding the issue:



10/12/2020 22:02:00,763 [7] INFO - Found 3 extensions for monitoring.

10/12/2020 22:02:01,483 [7] INFO - Ring-Central for TCP Client started at 192.168.3.27:2405

10/12/2020 22:02:01,495 [7] INFO - Sending SIP Register

10/12/2020 22:02:01,689 [8] INFO - Response: Trying

10/12/2020 22:02:01,695 [8] INFO - Response: Unauthorised

10/12/2020 22:02:01,697 [8] INFO - Sent SIP Register with authentication

10/12/2020 22:02:01,885 [8] INFO - Response: Trying

10/12/2020 22:02:01,923 [8] INFO - Response: Ok

10/12/2020 22:02:01,923 [8] INFO - Register successfully

10/12/2020 22:02:01,934 [7] INFO - Client authorized to https://platform.devtest.ringcentral.com with extension 302

10/12/2020 22:02:01,966 [7] INFO - Subscribed to listen events.

10/12/2020 22:02:05,886 [18] INFO - Setup call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: +442035452175(), To: 303()

10/12/2020 22:02:05,930 [18] INFO - Setup call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: +442035452175(), To: 303()

10/12/2020 22:02:06,162 [18] INFO - Answered call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: +442035452175(Stojan Trpchevski), To: 303(Petre Dimov)

10/12/2020 22:02:06,168 [18] INFO - Party id: p-ef3a274a206041b2a93bdaf97a77407e-1, direction: Outbound, from: +442035452175

10/12/2020 22:02:10,579 [18] INFO - Proceeding call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: 304(Stojan Trpchevski), To: 303(Petre Dimov)

10/12/2020 22:02:14,530 [18] INFO - Answered call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: 304(Stojan Trpchevski), To: 303(Petre Dimov)

10/12/2020 22:02:14,531 [18] INFO - Party id: p-ef3a274a206041b2a93bdaf97a77407e-2, direction: Inbound, from: 304

10/12/2020 22:02:14,541 [18] INFO - Trying top supervise by party: p-ef3a274a206041b2a93bdaf97a77407e-1

10/12/2020 22:02:15,254 [8] INFO - Request: INVITE

10/12/2020 22:02:15,256 [8] INFO - Sending Ringing (INVITE) response on request: 71af8498-5b9f-4aa0-b504-b91ab054bd62

10/12/2020 22:02:15,267 [8] INFO - Sending 200 OK (INVITE) response on request: 71af8498-5b9f-4aa0-b504-b91ab054bd62

10/12/2020 22:02:20,334 [18] ERROR - System.AggregateException: One or more errors occurred. ---> RingCentral.RestException: Response:

StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:

{
  Connection: keep-alive
  X-Rate-Limit-Group: light
  X-Rate-Limit-Limit: 50
  X-Rate-Limit-Remaining: 49
  X-Rate-Limit-Window: 60
  RoutingKey: SJC12P01
  RCRequestId: fae33b20-3b2a-11eb-80a8-005056bb0d1e
  Date: Thu, 10 Dec 2020 21:02:20 GMT
  Server: nginx
  Content-Length: 140
  Content-Type: application/json
}
Content: {
   "errors" : r
      {
         "errorCode" : "TAS-119",
         "message" : "Can't reach deviceId specified in request"
      }
   ]
}


10/12/2020 22:02:20,355 <18] INFO - Proceeding call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: 302(Zoran Kirov), To: +442035452175(Stojan Trpchevski)

10/12/2020 22:02:22,359 <18] INFO - Disconnected call: Tel-Session-Id: s-ef3a274a206041b2a93bdaf97a77407e, From: 302(Zoran Kirov), To: +442035452175(Stojan Trpchevski)

10/12/2020 22:02:22,360 <18] INFO - Details: Ringing: 9secs, duration: 6secs, call type: regular


It looks like you receive the tel session event notification with the "Answered" tel status then rush to register for supervision using the p-xxxxx-1 party id. I can verify which party is that p-xxxx-1 but most of the time you should detect the party you want to supervise/record. See my code staring from getting the "Answered" tel status of a call to read tel session info and detect parties before registering for supervise.

for (var party of jsonObj.body.parties){
if (party.direction === "Inbound"){
if (party.status.code === "Proceeding"){
if (agentInfo.id == party.extensionId)
sendPhoneEvent('ringing')
}else if (party.status.code === "Answered"){
if (agentInfo.id == party.extensionId)
getCallSessionInfo(jsonObj)
}else if (party.status.code === "Disconnected"){
...

Then https://github.com/PacoVu/ringcentral-supervision-demo/blob/master/index.js#L332

Let me know


@Phong Vu
Previous log was a little bit messy, cause party-id were not right. I will display the correct log from the code flow:

11/12/2020 11:49:41,951 [7] INFO  - Found 3 extensions for monitoring.  
11/12/2020 11:49:42,683 37] INFO  - Ring-Central for TCP Client started at 192.168.3.27:1233  
11/12/2020 11:49:42,695 67] INFO  - Sending SIP Register  
11/12/2020 11:49:42,887 28] INFO  - Response: Trying  
11/12/2020 11:49:42,893 :8] INFO  - Response: Unauthorised  
11/12/2020 11:49:42,895 48] INFO  - Sent SIP Register with authentication  
11/12/2020 11:49:42,974 17] INFO  - Client authorized to https://platform.devtest.ringcentral.com with extension 302  
11/12/2020 11:49:42,999 7] INFO  - Subscribed to listen events.  
11/12/2020 11:49:43,083 28] INFO  - Response: Trying  
11/12/2020 11:49:43,130 28] INFO  - Response: Ok  
11/12/2020 11:49:43,130 28] INFO  - Register successfully  
11/12/2020 11:49:45,107 /19] INFO  - Setup call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-1, Direction: D_OUTGOING, Local Ext. id: 684593005, Remote Ext. id  From: +442035452175(), To: 303()  
11/12/2020 11:49:45,144 19] INFO  - Setup call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-2, Direction: D_INCOMING, Local Ext. id: 684593005, Remote Ext. id 684343005 From: 304(Stojan Trpchevski), To: 303(Petre Dimov)  
11/12/2020 11:49:45,253 /19] INFO  - Answered call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-1, Direction: D_OUTGOING, Local Ext. id: 684593005, Remote Ext. id 684343005 From: +442035452175(Stojan Trpchevski), To: 303(Petre Dimov)  
11/12/2020 11:49:45,262 r19] INFO  - Party id: p-bc6b18991a26415999ee0715530473b5-1, direction: Outbound, from: +442035452175  
11/12/2020 11:49:49,678 <19] INFO  - Proceeding call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-2, Direction: D_INCOMING, Local Ext. id: 684593005, Remote Ext. id 684343005 From: 304(Stojan Trpchevski), To: 303(Petre Dimov)  
11/12/2020 11:49:50,059 Â19] INFO  - Answered call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-2, Direction: D_INCOMING, Local Ext. id: 684593005, Remote Ext. id 684343005 From: 304(Stojan Trpchevski), To: 303(Petre Dimov)  
11/12/2020 11:49:50,061 )19] INFO  - Party id: p-bc6b18991a26415999ee0715530473b5-2, direction: Inbound, from: 304  
11/12/2020 11:49:50,297 319] INFO  - Trying top supervise by party: p-bc6b18991a26415999ee0715530473b5-1, for device 801538285005, agent extension 684593005  
11/12/2020 11:49:51,001 98] INFO  - Request: INVITE  
11/12/2020 11:49:51,002 8] INFO  - Sending Ringing (INVITE) response on request: 56f39f4f-db96-48f6-9cd0-0a25112d8a41  
11/12/2020 11:49:51,016 58] INFO  - Sending 200 OK (INVITE) response on request: 56f39f4f-db96-48f6-9cd0-0a25112d8a41  
11/12/2020 11:49:56,108 a19] ERROR -  System.AggregateException: One or more errors occurred. ---> RingCentral.RestException: Response:
StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: keep-alive
  X-Rate-Limit-Group: light
  X-Rate-Limit-Limit: 50
  X-Rate-Limit-Remaining: 47
  X-Rate-Limit-Window: 60
  RoutingKey: SJC12P01
  RCRequestId: 97e1081c-3b9e-11eb-8e9a-005056bb0d1e
  Date: Fri, 11 Dec 2020 10:49:55 GMT
  Server: nginx
  Content-Length: 140
  Content-Type: application/json
}
Content: {
   "errors" : n
      {
         "errorCode" : "TAS-119",
         "message" : "Can't reach deviceId specified in request"
      }
   ]
}

Request:
Method: POST, RequestUri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/telephony/sessions/s-bc6b18991a26415999ee0715530473b5/parties/p-bc6b18991a26415999ee0715530473b5-1/supervise', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
  X-User-Agent: Unknown/0.0.1 RingCentral.Net/4.1.0
  Authorization: Bearer U0pDMTJQMDFQQVMwMHxBQUFaWGRoS2FoMDNDNUMyVXdGejVMRW15UnNoUzVYYzFuTWlxOGZiYmVieG1ZWmtVekI1S2ZMdUJqZVMwczlhM052bGJCZF9ucEtkMUpIQjZqOFdqT3JRaVNPVndWNWJYYW8yUkxmSmZubWdhWEVTamdOV203eXZZQXhtMGp3b2E5QnVUNk1EaFRReDJJTWRieWtjSVR4Q3l5aE5qeHk1NmFYdUh5aVRKbnZGY3NIeEQ4VTg4bVo0aC0yb2NJdXo5UXxGdlg5dHd8TW5Jczk0amwtUUp0eXdWZXJjNG5qZ3xBUQ
  Content-Type: application/json; charset=utf-8
  Content-Length: 84
}
 
11/12/2020 11:49:56,128 =19] INFO  - Proceeding call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-3, Direction: D_INCOMING, Local Ext. id: 684286005, Remote Ext. id 684593005 From: 302(Zoran Kirov), To: +442035452175(Stojan Trpchevski)  
11/12/2020 11:49:58,168 Z19] INFO  - Disconnected call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-3, Direction: D_INCOMING, Local Ext. id: 684286005, Remote Ext. id 684593005 From: 302(Zoran Kirov), To: +442035452175(Stojan Trpchevski)  
11/12/2020 11:49:58,169 219] INFO  - Details: Ringing: 0secs, duration: 11secs, call type: missed  



How do you make that inbound call? Calling from one extension to another extension using the main company number and extension number? If this is the case, it is complicated and hard to follow and explain => Create a support ticket rather than asking in the forum.


The log is still messy and I am not clear about who called whom? I assume that this is just a call leg between extensions but your log show "Local Ext. id: 684593005, Remote Ext. id 684343005". Are they from different RingCentral accounts?


11/12/2020 11:49:45,253 [19] INFO - Answered call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-1, Direction: D_OUTGOING, Local Ext. id: 684593005, Remote Ext. id 684343005 From: +442035452175(Stojan Trpchevski), To: 303(Petre Dimov)

E.g. if you try to supervise an incoming call to 303, this could be the event for you to use for the supervising request.

11/12/2020 11:49:50,059 [19] INFO - Answered call: Tel-Session-Id: s-bc6b18991a26415999ee0715530473b5, Party: p-bc6b18991a26415999ee0715530473b5-2, Direction: D_INCOMING, Local Ext. id: 684593005, Remote Ext. id 684343005 From: 304(Stojan Trpchevski), To: 303(Petre Dimov)


I'm calling from extension 303 to extension 304. Both extensions are registered on RingCentral phone windows application. There are not in same network, also the supervise device 302 is not in same network. The 302 is registered programmatically with API calls. It's mention in posts above.


Here are information regarding both extensions registered:

1607702035753.png
1607702078084.png

I would like to ask you if it's possible to setup a meeting call whenever you can, and I will demonstrate all the process and code flow, it won't take more than 15mins. If it's easier like this let me know. Or I can make a video regarding our process, how we make the call between the extensions.

Please let me know how to continue on this if it's possible.


Do you use Glip? Just send you a test message.


Also Instead of softphone in your example we are using TCP client from TcpClient class. When we doing supervise we also receive INVITE sip message to our TCP Client and we are trying to repond with 200 OK. On responding our supervise call throw exception with particular error:

Can you reproduce the issue using https://github.com/ringcentral/ringcentral-softphone-js ?

If the answer is no, then the root cause is in your TCP softphone client. It is not qualified as a softphone client to properly answer a phone call, thus "Can't reach deviceId specified in request".


First and foremost, make sure the RingCentral device you created is really able to answer an incoming call.

So when you get an INVITE message, you need to do this https://github.com/ringcentral/ringcentral-softphone-js/blob/master/src/index.ts#L50-L54

Followed by this https://github.com/ringcentral/ringcentral-softphone-js/blob/master/src/index.ts#L241-L249

Please double check and let me know if your code is all good.


We are also trying to implement the SIP phone in .net core. We have registered out Existing Phone (SIP Phone) in service.devtest.ringcentral.com portal. After registration we got the device id that we are trying to use to supervise the call using that SIP Phone. But whenever we hit the https://platform.devtest.ringcentral.com/restapi/v1.0/account/accountId/telephony/sessions/telephonySessionId/supervise api we are getting the same error mentioned in this article "Can't reach deviceId specified in request". Also, we have checked the status of Existing Phone and it is showing as Online. Could you please help to resolve this issue.


Reply