Skip to content

WEBRTC-2732: Fix network error dialog shown after user disconnection #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: WEBRTC-2705
Choose a base branch
from

Conversation

ai-swe-agent
Copy link
Contributor

Summary

Fixes issue where network error dialogs were shown after user intentionally disconnects from WebRTC session.

Problem

When users clicked the 'Disconnect' button, they would sometimes see error dialogs appearing after the intentional disconnect. This created confusion as users expected a clean disconnect without error messages.

Solution

  • Added isIntentionalDisconnect flag to track when disconnection is user-initiated
  • Modified handleError() method to suppress error dialogs when disconnect is intentional
  • Flag is set to true in disconnect() method when user manually disconnects
  • Flag is reset on successful login and after disconnect completes

Changes

  • TelnyxViewModel.kt: Added intentional disconnect tracking logic
    • New private flag isIntentionalDisconnect
    • Set flag in disconnect() method
    • Check flag in handleError() to suppress dialogs
    • Reset flag in handleLogin() and handleDisconnect()

Testing

  • User can disconnect without seeing error dialogs
  • Network errors during active sessions still show appropriate error dialogs
  • Reconnection works properly with flag reset

Related

  • Jira: WEBRTC-2732
  • Affects both XML and Compose sample apps

- Add isIntentionalDisconnect flag to track user-initiated disconnects
- Suppress error dialogs when user manually clicks disconnect button
- Reset flag on successful login and after disconnect completes
- Prevents confusing error messages when user intentionally disconnects
@wojciechowskiradek wojciechowskiradek changed the base branch from main to WEBRTC-2705 May 30, 2025 12:05
Copy link
Collaborator

@Oliver-Zimmerman Oliver-Zimmerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how I feel about the changes on the SDK side. I need to think about this some more

@@ -1929,6 +1932,9 @@ class TelnyxClient(
invalidateGatewayResponseTimer()
resetGatewayCounters()
unregisterNetworkCallback()
socket.destroy()

Handler(Looper.getMainLooper()).postDelayed(Runnable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about this.

we onDisconnect manually sometimes to destroy the socket to ensure we get push notifications. I don't know about adding an artificial delay.

On the other hand, 500ms isn't huge in the grand scheme of things. I would prefer to try solve this on the client side somehow though...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can fix this at the telnyx_common side by adding a variable, which will be set to true when the disconnection action comes from the user. In this case we can change handling error to handling disconnection. However I'm not sure which solution is less elegant...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants