Support Topics Documentation Slack YouTube Blog

Long run listener

Hi Team,

I am using SDK with TVOS. My TVOS app running continuously. As per my requirement i need to update data instantly when user perform any activity.

For this i used Create,Update and delete listener. Initially they work fine but after some they disconnected from backendless server.

As per my requirement i need permanent connection. Could you please help how to achieve this.

Now very crucial time need quick help

Hello, @Vinod_Sahu,

Could you please provide more information about that situation when listeners are disconnected?
What disconnect message do you receive?

Regards,
Olha

automatically disconnect after few hrs

But could you please provide a message that describes the reason for disconnection?
You can handle the connection events using these listeners:

Backendless.shared.rt.addConnectEventListener(responseHandler: (() -> Void))
Backendless.shared.rt.addConnectErrorEventListener(responseHandler: ((String) -> Void))
Backendless.shared.rt.addReconnectAttemptEventListener(responseHandler: (ReconnectAttemptObject) -> Void)!)
Backendless.shared.rt.addDisсonnectEventListener(responseHandler: ((String) -> Void)!)

This one

Backendless.shared.rt.addDisсonnectEventListener(responseHandler: ((String) -> Void)!)

will describe the reason of disconnection.

Regards,
Olha

For now just handling below listner

Backendless.shared.rt.addConnectEventListener

Can you provide me description about these listner

Backendless.shared.rt.addConnectEventListener(responseHandler: (() -> Void))

notifies you when socket is successfully connected to server


Backendless.shared.rt.addConnectErrorEventListener(responseHandler: ((String) -> Void))

notifies you about the error that appeared when trying to connect socket to server (socket connection failed)


Backendless.shared.rt.addReconnectAttemptEventListener(responseHandler: (ReconnectAttemptObject) -> Void)!)

notifies you about the reconnect attempt. E.g. If your socket lost connection it will try to reconnect automatically.


Backendless.shared.rt.addDisсonnectEventListener(responseHandler: ((String) -> Void)!)

notifies you that your socket has been disconnected from server and shows the reason. E.g. it may be the issue on the server side.


Thats why could you please provide the message received from the DisсonnectEventListener?
It should tell the reason of that disconnection.

Regards,
Olha

Ok Implementing these and then share you details.

Is there any way to identify particular listener connect to server or not ?

Is there any way to identify particular listener connect to server or not ?

No, right now we don’t provide that functionality.

… addConnectErrorEventListener … Cannot connect to Backendless

Hi Olha,

I notice that some time if internet disconnect for longer time then it not reconnect automatically to server and get this error

… addConnectErrorEventListener … Cannot connect to Backendless

What should i do if automatically not connected

Hello @Vinod_Sahu,

Issue has been fixed. Please update to v6.3.0. Socket will try to reconnect automatically if the connect error occurs.

Regards,
Olha

Hi @Vinod_Sahu

If the internet connection is not available, of course you will receive the error message

addConnectErrorEventListener … Cannot connect to Backendless

Because socket tries to connect to the server (without success). So this is expected behaviour.

Once the internet becomes available, the socket will automatically reconnect. But notice that there can be some delay.
That is because the timeout between reconnect attempts increases after some time. The timeout max value is 1 min, so there can be up to 1 min delay between internet becoming available and socket reconnecting.

Best Regards,
Maksym