ConnectyCube / connectycube-flutter-samples

Code samples for Flutter, based on ConnectyCube platform
https://developers.connectycube.com/flutter/
Apache License 2.0
85 stars 90 forks source link

For internet connection management of ConnectyCube SDK #117

Closed xspire closed 2 weeks ago

xspire commented 3 years ago

I have one suggestion for ConnectyCube SDK.

Add a management for AppLifecycleState and ConnectivityResult to ConnectyCube SDK.

This is to allow developers to determine the app state by looking only at the CubeChatConnectionState state value.

We found a situation that xmpp_stone in ConnectyCube SDK does not accurately reflect the current device state.

Sometimes, xmpp_stone is holded in a several state ( xmpp.XmppConnectionState.Authenticated, SocketOpening ... ) in a situation what internet connection is very often changed between wifi and LTE.

It is very defficult that developer manage the online connection.

Currently, is there perfect connection management solution for an unstable internet connection with ConnectyCube SDK ?

I spent too much time for stabilizing internet connection management with ConnectyCube SDK.

Ps : I use flutter Connectivity_plus plugin package for internet connection management.

TatankaConCube commented 3 years ago

We provided worked example for managing Internet state in our Chat sample. Which problem do you have with this implementation?

xspire commented 3 years ago

State of SDK is very often frozen in Reconnecting, Authenticated, SocketOpening,.. when changing between wifi and LET. To escape this stat, restart app. I have not yet fined a solution for this situation. I am spending 5 month for this issue.

TatankaConCube commented 3 years ago

have you reviewed my link? there we try to reconnect to the chat if the chat connection state changed to Closed or ForceClosed and connectivityType != ConnectivityResult.none. Or vice versa, when the connection state is changed to connectivityType != ConnectivityResult.none we check the state of the chat connection and try to reconnect if need.

xspire commented 3 years ago

Of course, I have used the activity_plus and app lifecycle hander. I mean that xmpp_stone state in connectycube api is holded freezied on a several state. FinaIly, i use watchdog to escape this situation, but the freezing state is not solved. Watchdog has been builded for checking holding state in any state what is not ready. When watchdog timeout is fired, recreate a session and chat login. I used the relogin function of connectycube sdk before, but it didn't work in any wifi, LTE situation. Also ConnectyCube SDK is freezied.

xspire commented 3 years ago

@TatankaConCube xmpp_stone is not adaptive to the Wi-Fi changing situation. (ex, iphone's personal hotspot and other wifi) You should check that mismatch between CubeChatConnectionState and XmppConnectionState. How to reset xmpp_stone connection ?

xspire commented 3 years ago

@TatankaConCube onConnectivityChanged handler of Connectivity does not be called when change any wifi to hotspot wifi.

Under stable wifi state, two xmpp message is periodically outputted with 5 seconds. That is "r xmlns="urn:xmpp:sm:3"" and "a xmlns='urn:xmpp:sm:3' h='69'".

But when wifi is exchanged, only one xmpp debug message is appeared. That is "r xmlns="urn:xmpp:sm:3"".

No handler is not called.

After about 3 minute, suddenly Outputing "CubeChatConnection: Chat connection ForcefullyClosed" debug message is started. After a moments, the connection is recovered.

I want to shrink the 3 minute. Where can i fix it ?

xspire commented 3 years ago

@TatankaConCube Socket Timeout is estimated at 6 minute.

xspire commented 3 years ago

@TatankaConCube I can't fined a timeout variable for handleSecuredConnectionError exception event what in Connection.dart of xmpp_stone. It is very serious.

xspire commented 3 years ago

Before about 6 minute, CubeChatConnection.instance.login does not return or call catError. If user restart app before 6 minute, Login is success. Is this a server issue too ? Where are you ?

TatankaConCube commented 3 years ago

Have you try to use method CubeChatConnection.instance.relogin instead of CubeChatConnection.instance.login? Could you please attach here full log from flutter console?

xspire commented 3 years ago

relogin and login, logout function is all failed after when device's ip is changed.

I find that xmpp's _socket is not destroyed when device's ip is changed. _socket?.destroy() code is not used anywhere in xmpp_stone and connectycube sdk.

Please check https://pub.dev/packages/network_info_plus flutter plugin.

Plesase test your flutter sample and improve your sdk for a daily use. I am spending my time too much for keeping online of your sdk.

TatankaConCube commented 3 years ago

Which version of our SDK do you use? How can we reproduce the same issue in our sample?

xspire commented 3 years ago

I am using ConntctyCube ver 2.0.2.

Test sequence.

  1. Run your chat sample app on android phone and iphone.
  2. Check that exchanging text message is stable.
  3. Open the network control pannel of device, and change the WiFi SSID to other WiFi SSID.
  4. Try sending and receiving message.
  5. Check how long time it takes for sending and receiving messages to resume.
xspire commented 3 years ago

@TatankaConCube Is there any activity ?

CubeRomanMagellan commented 2 weeks ago

no activity for a long time, closing.