powered by Jive Software

Smack BOSH connection with crash

I am doing a chat module demo using a BOSH connection with SMACK.
SmackConnection.kt (9.8 KB)
Here I upload my connection class file. In that, domain and port are dummies currently due to privacy.

When I open the login screen where I am just calling below lines on start:

smackConnection = SmackConnection.getInstance(this@LoginActivity)
                smackConnection!!.getConnection()

After waiting for few seconds without doing anything, It crashes with below error:

java.lang.IllegalStateException: Connection already open
        at org.apache.http.util.Asserts.check(Asserts.java:34)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:133)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
        at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:674)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:487)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:235)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1123)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:999)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1728)
        at java.lang.Thread.run(Thread.java:919)