Smack/smack-core/src/main/java/org/jivesoftware/smack
Florian Schmaus 1a2a613112 Set 'connected' to 'true' as early as possible
We previously only set 'connected' after connectInternal()
returned. This could lead to notifyConnectionError() ignoring stream
error exceptions, e.g. when establishing TLS which happens also in
connectInternal(), because 'connected' was still 'false'.

2020-08-06 13:08:06.265 19830-20423/org.atalk.android D/SMACK: SENT (0):
    <stream:stream xmlns='jabber:client' to='atalk.sytes.net' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
2020-08-06 13:08:06.333 19830-20424/org.atalk.android D/SMACK: RECV (0): ?xml version='1.0'?>
    <stream:stream id='16420577292739412012' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='atalk.sytes.net' xmlns='jabber:client'>
    <stream:error>
      <policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
      <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
        Too many (20) failed authentications from this IP address (::ffff:42.60.7.13). The address will be unblocked at 05:15:34 06.08.2020 UTC
      </text>
    </stream:error>
    </stream:stream>
2020-08-06 13:08:06.346 19830-20424/org.atalk.android I/aTalk: [241896] org.jivesoftware.smack.AbstractXMPPConnection.notifyConnectionError() Connection was already disconnected when attempting to handle org.jivesoftware.smack.XMPPException$StreamErrorException: policy-violation You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
    <stream:error><policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'>Too many (20) failed authentications from this IP address (::ffff:42.60.7.13). The address will be unblocked at 05:15:34 06.08.2020 UTC</text></stream:error>
    org.jivesoftware.smack.XMPPException$StreamErrorException: policy-violation You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
    <stream:error><policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'>Too many (20) failed authentications from this IP address (::ffff:42.60.7.13). The address will be unblocked at 05:15:34 06.08.2020 UTC</text></stream:error>
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:966)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:898)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:921)
        at java.lang.Thread.run(Thread.java:919)

Which eventually leads to a NoResponseException

org.jivesoftware.smack.SmackException$NoResponseException: No response
received within reply timeout. Timeout was 30000ms (~30s). While
waiting for establishing TLS
[XMPPTCPConnection[not-authenticated] (4)]

We now set 'connected' to 'true' as soon as the transport (e.g. TCP,
BOSH, …) is connected. While this is in other ways also sensible, it
also allows notifyConnectionError() to handle exceptions in the early
connection stage.

Thanks to Eng Chong Meng for reporting this.
2020-08-06 16:32:26 +02:00
..
altconnections Add support for HTTP lookup method through xep-0156 2020-06-25 21:10:43 +05:30
bind2 Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
c2s Set 'connected' to 'true' as early as possible 2020-08-06 16:32:26 +02:00
compress Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
compression Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
datatypes Fix datatype.Scalar equals() and hashCode() methods 2019-10-17 12:24:30 +02:00
debugger [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
filter [core] Add StanzaFilter.asPredicate(Class) 2020-05-18 09:15:14 +02:00
fsm [core] Add String-based StateDescriptor precedence/inferiority declaration methods 2020-07-25 14:27:45 +02:00
initializer Introduce CloseableUtil 2018-08-15 17:25:22 +02:00
internal [core] Rework TLS logic 2020-05-25 15:41:57 +02:00
iqrequest Use QName instead of XmppStringUtils.generateKey() 2019-06-11 12:47:39 +02:00
isr Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
packet Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
parsing Re-work data form API 2020-05-13 20:14:41 +02:00
provider Implement message stanza <thread/> and <subject/> as ExtensionElement 2020-04-05 18:58:13 +02:00
proxy proxy: modernize code by using (ByteArrayOutput|DataInput)Stream 2020-02-23 19:12:54 +01:00
sasl [sasl] Rename getChannelBindingName() to getGs2CbindFlag() 2020-07-02 13:07:17 +02:00
util Merge branch 'master' of github.com:igniterealtime/Smack 2020-07-18 21:47:06 +02:00
AbstractConnectionClosedListener.java [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
AbstractConnectionListener.java [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
AbstractXMPPConnection.java Set 'connected' to 'true' as early as possible 2020-08-06 16:32:26 +02:00
AsyncButOrdered.java core: improve AsyncButOrdered 2019-11-08 10:14:21 +01:00
ConnectionConfiguration.java [core] Rework TLS logic 2020-05-25 15:41:57 +02:00
ConnectionCreationListener.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
ConnectionListener.java Add callback method for when Smack is connecting 2020-07-18 12:50:08 +02:00
ExceptionCallback.java Merge branch '4.2' into master-paul-merged 2017-12-17 11:16:02 +01:00
Manager.java [core] Introduce ScheduledAction.Kind for blocking and non-blocking actions 2020-05-18 09:15:14 +02:00
MessageListener.java Enable javadoc checkstyle 2015-03-29 12:29:32 +02:00
NonzaCallback.java Move SASL logic into AbstractXMPPConnection 2019-09-25 13:49:21 +02:00
PacketListener.java Enable javadoc checkstyle 2015-03-29 12:29:32 +02:00
PresenceListener.java Enable javadoc checkstyle 2015-03-29 12:29:32 +02:00
ReconnectionListener.java Fix minor codestyle issues 2017-12-17 11:03:46 +01:00
ReconnectionManager.java [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
SASLAuthentication.java Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
ScheduledAction.java [core] Introduce ScheduledAction.Kind for blocking and non-blocking actions 2020-05-18 09:15:14 +02:00
SmackConfiguration.java Remove deprecated methods/fields scheduled for removal in Smack 4.4 2020-04-04 13:03:48 +02:00
SmackException.java NoEndpointDiscoveredException: s/Not/No 2020-07-28 19:00:04 +02:00
SmackFuture.java Introduce Smack's Modular Connection Architecture 2020-04-04 13:03:31 +02:00
SmackInitialization.java core: use addCompressionHandler() instead directly adding to the list 2020-04-09 15:14:09 +02:00
SmackReactor.java [core] Do not weakly reference "channel selected" callback 2020-05-30 19:45:59 +02:00
StanzaCollector.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
StanzaListener.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
UnparseableStanza.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
XMPPConnection.java Add XMPP.(get|has)Feature(Class|QName) and deprecate (String, String) 2020-07-23 14:32:14 +02:00
XMPPConnectionRegistry.java Enable trailing whitespace checkstyle check 2018-05-09 23:26:39 +02:00
XMPPException.java Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
XmppInputOutputFilter.java Remove SynchronizationPoint 2020-05-31 19:48:47 +02:00
package-info.java Add JavadocPackage checkstyle 2015-04-04 17:16:47 +02:00