Question

ping pong using .net sdk example

  • 19 September 2023
  • 3 replies
  • 168 views

I am looking for examples on how to properly handle ping/pong requests using the .net sdk when using websockets.

Currently the sdk does not seem automatically handle this and the servers gets disconnected after some time du to inactivity.

My understanding is that after some time, the ringcentral server will send a ping frame and we need to respond (somehow) to this with a pong frame according to this documentation: https://developers.ringcentral.com/guide/notifications/websockets/heart-beats

I can`t find any examples on how to accomplish this using the .net sdk.

Thanks.


3 replies

This should be fixed in the SDK. I am the author of the SDK and I remember that I tested this case. It is handled by this line: https://github.com/ringcentral/RingCentral.Net/blob/master/RingCentral.Net.WebSocket/WebSocketExtension.cs#L39

Could you please elaborate how to reproduce this issue? Like wait how long to have it disconnected?


Hi Tyler,

Yeah it`s hard to tell exactly what is going on, we are trying to figure it out, the code is very simple.

From what we figured out so far, it does not seem to be the websocket connection not working, but instead that the subscription is not longer receiving messages.

We were able to test this by doing:

wsExtension.MessageReceived += WsExtension_MessageReceived;

And we saw that we still receive messages through the websocket. But the messages no longer make it to this part after something like 2 minutes.

var subscription = await wsExtension.Subscribe(new string[] { "/restapi/v1.0/account/~/telephony/sessions" }, async (jsonMessage) => ...

If we do a simple while loop and call: subscription.Refresh() every minute it seems like it works. But this seems to be undocumented if that is the way we are supposed to do it.

@Tyler Liu can you confirm if calling subscription.Refresh() every minute manually is the right way to go?

Reply