vukoye / xmpp_dart

Lightweight XMPP client library written in Dart
Apache License 2.0
83 stars 64 forks source link

Logout and second login with same user issue #18

Closed TatankaConCube closed 4 years ago

TatankaConCube commented 4 years ago

Version: 0.2.3 Steps:

  1. create connection with User_1:
    String userJid = ""; // full user jid
    xmpp.XmppAccountSettings accountSettings = xmpp.XmppAccountSettings.fromJid(userJid, password);
    xmpp.Connection _connection = xmpp.Connection.getInstance(accountSettings);
    _connection.connect();
  2. close connection for User_1:
    _connection.close();
  3. try connect again with same user:
    _connection.connect();

I investigated code of your file Connection.dart and found issue here, I think you mean '=' instead of '==';

After changes in this place second login was started but didn't call all steps for login, just stoped after process features.

If you need more informations or logs, please let me know.

TatankaConCube commented 4 years ago

Do you have any thinks about this issue?

vukoye commented 4 years ago

Hi Tatanka, Can you please check if issue is fixed with latest push? I test it with few seconds delay between connect close and connect

TatankaConCube commented 4 years ago

The issue still reproduces on current master branch from this repo. My second login stoped on state State: XmppConnectionState.DoneParsingFeatures but not State: XmppConnectionState.Ready like expected. Here full log with second login.

I tried use workaround and create new instance of Connection every time. What I mean:

_connection = xmpp.Connection(account);
_connection.connect();

then for logout use

_connection.close();
_connection = null;

then second login

_connection = xmpp.Connection(account); 
_connection.connect();

but in this case after second login this code stoped wort, this stream stoped triggering although a receive incoming messages

_messageHandler = MessageHandler.getInstance(connection);
_messageHandler.messagesStream.listen((messageStanza) {
  onReceiveNewMessageStanza(messageStanza);
});
TatankaConCube commented 4 years ago

@vukoye I investigated this issue again. It looks like issue related with sending package "http://jabber.org/protocol/disco#info"

I/flutter ( 2793): sending: <iq id="CLQYNURMR" type="get" from="1425506-476@chat.connectycube.com/flutter_48ec3d2f0044e518" to="chat.connectycube.com">
I/flutter ( 2793):   <query xmlns="http://jabber.org/protocol/disco#info"/>
I/flutter ( 2793): </iq>

this package doesn't send during second login.

It is because ConnectionNegotatiorManager adds ServiceDiscoveryNegotiator as singleton and on second login method pickNextNegotatiator() didn't return this negotiator because its state is NegotiatorState.DONE on second login.

Second unclear pieces of code: https://github.com/vukoye/xmpp_dart/blob/master/lib/src/features/ConnectionNegotatiorManager.dart#L134 and https://github.com/vukoye/xmpp_dart/blob/master/lib/src/features/ConnectionNegotatiorManager.dart#L140 this code does nothing.

@vukoye can you please review ConnectionNegotatiorManager I think it is reason of issues related with second login.

TatankaConCube commented 4 years ago

@vukoye I prepared Merge request https://github.com/vukoye/xmpp_dart/pull/27 Please review it and apply.