I am facing a connection issue while connecting using TCP/TLS connection. Below is my code for that:
private fun buildTCPConfiguration(): XMPPTCPConnectionConfiguration {
var sslContext = SSLContext.getInstance("TLS")
var mtm = MemorizingTrustManager(mContext)
sslContext.init(
null,
arrayOf<X509TrustManager>(mtm),
SecureRandom()
)
val builder =
XMPPTCPConnectionConfiguration.builder()
.setXmppDomain("dev-xmpp.thest.io")
.enableDefaultDebugger()
.setSecurityMode(ConnectionConfiguration.SecurityMode.ifpossible)
.setCompressionEnabled(false)
.setResource("test")
.setUsernameAndPassword("apurv", "Test@123")
.setSendPresence(false)
.setCustomSSLContext(sslContext)
.setHostnameVerifier(mtm.wrapHostnameVerifier(CustomDomainVerifier()))
// .addEnabledSaslMechanism(SASLXOauth2Mechanism.NAME)
.build()
return builder
}
above is my builder for connection which I am using like below:
val config = buildTCPConfiguration()
SmackConfiguration.DEBUG = true
connection = XMPPTCPConnection(config)
connection!!.connect()
While running, I am getting below logcat:
2020-08-29 12:29:21.938 21838-22092/com.example.smackandroidsample D/XmppDomainVerifier: searching for dev-xmpp.thest.io in srvNames: [] xmppAddrs: [] domains:[dev-xmpp.thest.io]
2020-08-29 12:29:21.938 21838-22092/com.example.smackandroidsample D/XmppDomainVerifier: domain dev-xmpp.thest.io matched dev-xmpp.thest.io
2020-08-29 12:29:21.941 21838-22091/com.example.smackandroidsample D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='dev-xmpp.thest.io' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='apurv@dev-xmpp.thest.io' xml:lang='en'>
2020-08-29 12:29:21.986 21838-22092/com.example.smackandroidsample D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream id='5518425261136120178' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' to='apurv@dev-xmpp.thest.io' from='dev-xmpp.thest.io' xmlns='jabber:client'>
2020-08-29 12:29:21.987 21838-22092/com.example.smackandroidsample D/SMACK: RECV (0): <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
2020-08-29 12:29:21.989 21838-22004/com.example.smackandroidsample D/XMPP-EXAMPLE: Time taken in first time connect: 870
2020-08-29 12:29:51.621 21838-22092/com.example.smackandroidsample D/SMACK: RECV (0): <stream:error><connection-timeout xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>Idle connection</text></stream:error>
2020-08-29 12:29:51.641 21838-22248/com.example.smackandroidsample W/AbstractXMPPConnection: Connection XMPPTCPConnection[not-authenticated] (0) closed with error
org.jivesoftware.smack.XMPPException$StreamErrorException: connection-timeout You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
<stream:error><connection-timeout xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'>Idle connection</text></stream:error>
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1164)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$1000(XMPPTCPConnection.java:1092)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1112)
at java.lang.Thread.run(Thread.java:919)
Is there anything I am missing here? Kindly help me with that.