Hi, We have implemented an XMPP chat server with ...
# android
m
Hi, We have implemented an XMPP chat server with Prosody. and i want to connect this Xmpp server to send and receive messages. but I got error in connecting to this server via smack library. here is my code to connect:
Copy code
private fun initChat() = GlobalScope.launch {
    initConnection()
}

private fun initConnection() {
    val config = XMPPTCPConnectionConfiguration.builder()
        .setXmppDomain("my domain")
        .setHost("my domain")
        .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
        .setCompressionEnabled(false)
        .setPort(5280)
        .build()
    
    val connection = XMPPTCPConnection(config)
    connection.connect()
    connection.login()
}
and there are my gradle dependency:
Copy code
implementation "org.igniterealtime.smack:smack-android:4.3.4"
implementation "org.igniterealtime.smack:smack-tcp:4.3.4"
implementation "org.igniterealtime.smack:smack-extensions:4.3.4"
and i got this error:
Copy code
org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). While waiting for establishing TLS
        at org.jivesoftware.smack.SynchronizationPoint.checkForResponse(SynchronizationPoint.java:317)
        at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWait(SynchronizationPoint.java:160)
        at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWaitOrThrow(SynchronizationPoint.java:131)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:977)
        at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:435)
        at ir.gharar.activities.LiveActivity.initConnection(LiveActivity.kt:78)
        at ir.gharar.activities.LiveActivity.access$initConnection(LiveActivity.kt:40)
        at ir.gharar.activities.LiveActivity$initChat$1.invokeSuspend(LiveActivity.kt:65)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
can anyone help me for that?
Do you know another library other than
Smack
for android to communicate with xmpp server?
Smack
is not well-documented
👍 1
b
Smack is the best library for xmpp socket
your issue is the security
please change the connection type
or ask your backend that which connection type they are supporting.
m
Actually my xmpp server is with prosody. do you have exprience with prosody and smack?
b
with prosody i dont have any experience . But your error look like its connection establishment issue because of protocol may be
m
I think the problem is maybe because of we use prosody and prosody differs a lot with openfire
199 Views