Skip to content

Connection Management

A client application running on a device or in a browser maintains a connection with the Backendless Real-Time Database. There is always only one connection for a single client, even though it may have multiple listeners for different data tables. The connection status can be tracked in the application using connection event handlers:

Connection Established Event

The event is dispatched when the client application establishes a connection with the Real-Time Database. Once a connection is established, real time database dispatches events triggered by the API calls to the client application. Add the following listener to be notified when the connection is established:

Backendless.RT.AddConnectListener( () =>
{
  Console.WriteLine( "Client connected" );
});

The "Connection Established" event takes place when the client application adds its very first API event listener. Additionally, the event may be triggered when the client reconnects with the real-time database after the connection is interrupted.

Disconnect Event

If the connection with the real-time database is dropped either due to network or server problems, the client application is notified via the following listener:

Backendless.RT.AddDisconnectListener( ( reason ) =>
{
  Console.WriteLine( $"Client disconnected. Disconnect reason - {reason}" );
});