Support Topics Documentation Slack YouTube Blog

Flutter RT Database connection error

Facing a “Connection failed” error when creating a Real Time database event handler for a custom data table. I tried attaching an event handler for a system table (Users) and I get the same error.

The below code snippets are from a minimal Flutter app, to reproduce the issue. Not shown, is the button for logging in with hard coded values before attempting to add the event handlers, to ensure we’re authenticated.

App ID: 10D48062-3F1B-573A-FF51-E119D6C58000

Flutter dependencies:
backendless_sdk: ^6.3.0

android/app/build.gradle:

    dependencies {
       implementation ('io.socket:socket.io-client:2.0.0') { 
         // excluding org.json which is provided by Android 
         exclude group: 'org.json', module: 'json' 
       }
    }

Backendless setup:

@override
void initState() {
	super.initState();
	Backendless.initApp(
	'10D48062-3F1B-573A-FF51-E119D6C58000',
	'MY_ANDROID_API_KEY',
	'MY_IOS_API_KEY',
	);
}

Adding connect listener:

void foo() {
Backendless.rt.addConnectListener(() => print('Connected'));
}

Attaching Event Handler:

void bar() {
EventHandler<UserSettings> eventHandler =
      Backendless.data.withClass<UserSettings>().rt();
      
eventHandler.addUpdateListener(
	(response) {
	  print('Updated data recieved: ${response.}');
	},
	whereClause: "objectId = '$userObjectId'",
	);
}

Error:

I/RTClient(28891): try to subscribe RTSubscription{id='0D55F562-3250-9DD1-FF4A-046296393F00', callback=com.backendless.rt.data.EventHandlerImpl$5@b526508, subscriptionName=OBJECTS_CHANGES, options={event=updated, tableName=UserSettings}}
I/cketIOConnectionManager(28891): Socket not connected. Try to get lock
I/cketIOConnectionManager(28891): Got lock
2
I/System.out(28891): (HTTPLog)-Static: isSBSettingEnabled false
I/cketIOConnectionManager(28891): Looked up for server https://rt-cloud-us.backendless.com:3001/10D48062-3F1B-573A-FF51-E119D6C58000
I/cketIOConnectionManager(28891): try to connect with to host with query: apiKey=<MY_ANDROID_API_KEY>&clientId=7a1e2a3e1805a56a&binary=true&userToken=D9C1DAE1-12BB-409F-BAF2-B69EBFA38B5A
I/cketIOConnectionManager(28891): Socket object created
W/socket_app_tes(28891): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, reflection, allowed)
W/socket_app_tes(28891): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
W/socket_app_tes(28891): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
E/cketIOConnectionManager(28891): Connection failed [io.socket.engineio.client.EngineIOException: server error]
I/cketIOConnectionManager(28891): Try to disconnect
I/cketIOConnectionManager(28891): Wait for 200 before reconnect
I/cketIOConnectionManager(28891): Socket not connected. Try to get lock
I/cketIOConnectionManager(28891): Got lock
2
I/System.out(28891): (HTTPLog)-Static: isSBSettingEnabled false
I/cketIOConnectionManager(28891): Looked up for server https://rt-cloud-us.backendless.com:3001/10D48062-3F1B-573A-FF51-E119D6C58000
I/cketIOConnectionManager(28891): try to connect with to host with query: apiKey=<MY_ANDROID_API_KEY>&clientId=7a1e2a3e1805a56a&binary=true&userToken=D9C1DAE1-12BB-409F-BAF2-B69EBFA38B5A
I/cketIOConnectionManager(28891): Socket object created
E/cketIOConnectionManager(28891): Connection failed [io.socket.engineio.client.EngineIOException: server error]
I/cketIOConnectionManager(28891): Try to disconnect
I/cketIOConnectionManager(28891): Wait for 200 before reconnect
I/cketIOConnectionManager(28891): Socket not connected. Try to get lock
I/cketIOConnectionManager(28891): Got lock
...

The error occurs after running bar().

Am I missing something on the client side? I followed the Client Side Setup section (which doesn’t mention adding socket.io dependency to build.gradle), but I don’t see any steps that I’ve missed. Any advice is appreciated!

Hello @John_Admin

I have created an internal ticket BKNDLSS-24678 to investigate your problem. We will let you know the result as soon as possible.

Regards,
Inna

1 Like

Hey @Inna_Shkolnaya, any update on this issue?

Thanks again!

Hello @John_Admin,

any update on this issue?

Not yet.
We will notify you here of any progress.

Regards,
Stanislaw