team-telnyx / flutter-voice-sdk

Telnyx Flutter WebRTC SDK - Enable real-time communication with WebRTC and Telnyx
MIT License
11 stars 5 forks source link

[Bug] Socket Message CLIENT_READY is not being logged properly #20

Closed icodelifee closed 1 year ago

icodelifee commented 1 year ago

Bug Category

SDK Version eg. telnyx_webrtc: latest

Describe the bug This only happens sometimes, but when i try to login with credentials sometimes the CLIENT_READY wont be logged. Please check the logs below

Expected behaviour socket method CLIENT_READY logs and should allow to receive or create calls

To Reproduce Steps to reproduce the behaviour:

  1. e.g. (Log on with credentials)
  2. e.g. (Socket error then returned)

Logs https://katb.in/sawawalikiz

icodelifee commented 1 year ago

I've been scratching my head over this issue for a couple of days now. Is there a way to know if the client has been logged in through the client class? because I'm relying on registered state variable in my notifier class which updates when observer triggers CLIENT_READY case to know that i have logged in and is ready to make calls

Oliver-Zimmerman commented 1 year ago

hey @icodelifee.

I can look into this for you - generally, though, the REGED state is what you should be looking for in terms of when the client is ready to make and receive calls.

icodelifee commented 1 year ago

hey @icodelifee.

I can look into this for you - generally, though, the REGED state is what you should be looking for in terms of when the client is ready to make and receive calls.

Yes, i know about REGED but the observer onSocketMessage handler is not logging any messages.

icodelifee commented 1 year ago

Hello, @Oliver-Zimmerman im having another issue, Websocket automatically closes. for now, i have a workaround, a timer which checks every couple of seconds if the telnyx client is connected or not. Should i create another issue?. logs below thanks. https://katb.in/opafixoqisu

Update: got a close with close reason Screenshot 2022-09-29 at 9 03 17 PM

Oliver-Zimmerman commented 1 year ago

@icodelifee sorry for the late reply, the mobile team is under heavy load at the moment. This is my priority today. I will look into both issues. and update you here

Oliver-Zimmerman commented 1 year ago

@icodelifee Can I ask if you are testing on iOS, Android or Web? Or is it happening on all?

Oliver-Zimmerman commented 1 year ago

Hey @icodelifee

In regards to the socket closing. This should be fixed by this PR https://github.com/team-telnyx/flutter-voice-sdk/pull/21

I can let you know once it has merged and we do a release, but you should be able to test it from there first if you like.

In regards to the client ready message. There might be some confusion as to how onSocketMessageReceived works.

I believe you are receiving Client Ready but are perhaps only looking at the message instead of the SocketMethod provided with the message. For example here is the Client_Ready socket method we receive on a successful REGED state: Screenshot 2022-10-05 at 10 51 12

We monitor this in our view model in the sample app like this, regardless of the containing message: Screenshot 2022-10-05 at 10 51 59

Oliver-Zimmerman commented 1 year ago

https://pub.dev/packages/telnyx_webrtc

The new version is available @icodelifee

telnyx_webrtc: ^0.0.8

Please close this issue if it is resolved, otherwise let me know here and we can investigate further

icodelifee commented 1 year ago

both issues. and update you here

Im testing on Android

icodelifee commented 1 year ago

Hey @icodelifee

In regards to the socket closing. This should be fixed by this PR #21

I can let you know once it has merged and we do a release, but you should be able to test it from there first if you like.

In regards to the client ready message. There might be some confusion as to how onSocketMessageReceived works.

I believe you are receiving Client Ready but are perhaps only looking at the message instead of the SocketMethod provided with the message. For example here is the Client_Ready socket method we receive on a successful REGED state: Screenshot 2022-10-05 at 10 51 12

We monitor this in our view model in the sample app like this, regardless of the containing message: Screenshot 2022-10-05 at 10 51 59

Oh, i also observe all the Telnyx messages using the messageRecieved handler Screenshot 2022-10-05 at 8 06 19 PM

icodelifee commented 1 year ago

Screenshot 2022-10-05 at 8 17 55 PM In the latest version im getting a stream sink close issue

icodelifee commented 1 year ago

Screenshot 2022-10-05 at 8 17 55 PM In the latest version im getting a stream sink close issue

After this error gets thrown, the messageReceived callback is not working

Oliver-Zimmerman commented 1 year ago

@icodelifee I can't reproduce this. Can you confirm it is happening on the sample app too? If not then I believe we need to look into your implementation.

I've had an application up and running for over 30 minutes now without the error: https://pastebin.pl/view/cb847a9e

icodelifee commented 1 year ago

@icodelifee I can't reproduce this. Can you confirm it is happening on the sample app too? If not then I believe we need to look into your implementation.

I've had an application up and running for over 30 minutes now without the error: pastebin.pl/view/cb847a9e

Its still happening, but only after i call from SIP number to my SIP number, i still dont know the correct way to reproduce it!, maybe the websocket closed and its trying to access it? before its being reconnected? im not sure

icodelifee commented 1 year ago

@icodelifee I can't reproduce this. Can you confirm it is happening on the sample app too? If not then I believe we need to look into your implementation. I've had an application up and running for over 30 minutes now without the error: pastebin.pl/view/cb847a9e

Its still happening, but only after i call from SIP number to my SIP number, i still dont know the correct way to reproduce it!, maybe the websocket closed and its trying to access it? before its being reconnected? im not sure

One thing i found is that it only happens after the debug message -> Received WebSocket message - Contains Method :: {jsonrpc: 2.0, id: 17786, method: telnyx_rtc.ping, params: {serno: 1665048277}}, if that can help

https://katb.in/acaserufema

Oliver-Zimmerman commented 1 year ago

Okay I will test after receiving a call and see if I can reproduce. I will update you here

Oliver-Zimmerman commented 1 year ago

@icodelifee and you're sure this is happening on the Sample app? I just ran a test logging in and receiving a call and then waiting for 2 successful Ping/Pong exchanges and it seems to be working. Video attached:

https://user-images.githubusercontent.com/9112652/194286037-0d62ca89-8a86-445a-bb6a-8f677f8197c2.mov

icodelifee commented 1 year ago

@icodelifee and you're sure this is happening on the Sample app? I just ran a test logging in and receiving a call and then waiting for 2 successful Ping/Pong exchanges and it seems to be working. Video attached:

Screen.Recording.2022-10-06.at.11.04.11.mov

Hey, i did some more testing, its fine the example app, i think its happening because i close the websocket after user logout. Is it necessary to disconnect the websocket when user sign out of the app and then relogs with a different credentials?

Oliver-Zimmerman commented 1 year ago

Hey @icodelifee

No that's not necessary. You can keep the same socket connection alive and just send another login message with the different credentials.

However, closing the socket theoretically shouldn't cause any issues if you then reopen it. I can look into this flow for you and see what is causing the issue. But for now, feel free to simply login with different credentials

Oliver-Zimmerman commented 1 year ago

hey @icodelifee

I found the issue with the disconnect. You can see the PR here. I will release a new version soon: https://github.com/team-telnyx/flutter-voice-sdk/pull/22

Oliver-Zimmerman commented 1 year ago

@icodelifee

Version 0.0.9 has been released. You should be able to use disconnect now.

Please close this issue if it is working for you

Oliver-Zimmerman commented 1 year ago

@icodelifee I am going to close this for now. Please re-open if the issue persists