Session is not connected to server.

Issue #72 closed
Harshit Bangar created an issue

Hi Scooter,

Thanks for babbler. It's awesome and extremely quick to prototype using java 8 and RXJava. I am using babbler for writing an echo bot but when using with fatjar it's giving me session not connected exception. The incoming messages are received properly but while sending outgoing messages it's giving issues. I tried putting break points and the flow looks fine.

OUT: <presence><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="SPDCGE7AJiFJBheQ9RTTNFnv+Gc="></c></presence>
IN : <presence from="ce22bf7d-2aeb-43a4-970b-c192b57a6652@ejabberd.sandwitch.in" to="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in" type="subscribe"><status></status></presence>
IN : <message from="ce22bf7d-2aeb-43a4-970b-c192b57a6652@ejabberd.sandwitch.in/smack" id="6pFzp-60" to="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in/smack" type="chat" xml:lang="en"><thread>22242314-bff8-40d6-9e1b-7be1dff914d0</thread><active xmlns="http://jabber.org/protocol/chatstates"></active><delay xmlns="urn:xmpp:delay" from="ejabberd.sandwitch.in" stamp="2016-01-24T04:56:37.647Z">Offline Storage</delay></message>
IN : <message from="ce22bf7d-2aeb-43a4-970b-c192b57a6652@ejabberd.sandwitch.in/smack" id="6pFzp-64" to="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in/smack" type="chat" xml:lang="en"><thread>22242314-bff8-40d6-9e1b-7be1dff914d0</thread><composing xmlns="http://jabber.org/protocol/chatstates"></composing><delay xmlns="urn:xmpp:delay" from="ejabberd.sandwitch.in" stamp="2016-01-24T04:56:39.555Z">Offline Storage</delay></message>
IN : <message from="ce22bf7d-2aeb-43a4-970b-c192b57a6652@ejabberd.sandwitch.in/smack" id="a539c2d2-0f4f-416c-9b88-bea36628a845" to="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in" type="chat" xml:lang="en"><body>lol</body><thread>7ddec50e-226c-47ba-b2f5-eef2f0c18e4c</thread><archived xmlns="urn:xmpp:mam:tmp" by="ejabberd.sandwitch.in" id="1453611430806005"></archived><stanza-id xmlns="urn:xmpp:sid:0" by="ejabberd.sandwitch.in" id="1453611430806005"></stanza-id><request xmlns="urn:xmpp:receipts"></request><json xmlns="urn:xmpp:json:0">{"subType":"TEXT","timestamp":1453611400224}</json><delay xmlns="urn:xmpp:delay" from="ejabberd.sandwitch.in" stamp="2016-01-24T04:56:40.673Z">Offline Storage</delay></message>
IN : <message from="ce22bf7d-2aeb-43a4-970b-c192b57a6652@ejabberd.sandwitch.in/smack" id="6pFzp-66" to="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in/smack" type="chat" xml:lang="en"><thread>22242314-bff8-40d6-9e1b-7be1dff914d0</thread><active xmlns="http://jabber.org/protocol/chatstates"></active><delay xmlns="urn:xmpp:delay" from="ejabberd.sandwitch.in" stamp="2016-01-24T04:56:40.769Z">Offline Storage</delay></message>
IN : <presence from="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in/babbler" to="42382d53-272e-4674-8079-453dc22ee412@ejabberd.sandwitch.in/babbler" xml:lang="en"><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="SPDCGE7AJiFJBheQ9RTTNFnv+Gc="></c></presence>
Jan 24, 2016 10:27:14 AM rocks.xmpp.util.XmppUtils lambda$notifyEventListeners$3
WARNING: Session is not connected to server
rx.exceptions.OnErrorNotImplementedException: Session is not connected to server
    at rx.Observable$31.onError(Observable.java:7134)
    at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:154)
    at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:137)
    at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:41)
    at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:30)
    at rx.Observable.subscribe(Observable.java:7393)
    at rx.Observable.subscribe(Observable.java:7125)
    at dictionary.bot.Bot.lambda$initializeConnection$2(Bot.java:77)
    at rocks.xmpp.util.XmppUtils.lambda$notifyEventListeners$3(XmppUtils.java:191)
    at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:890)
    at java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:404)
    at rocks.xmpp.util.XmppUtils.notifyEventListeners(XmppUtils.java:189)
    at rocks.xmpp.core.session.XmppSession.lambda$handleElement$9(XmppSession.java:827)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Session is not connected to server
    at rocks.xmpp.core.session.XmppSession.send(XmppSession.java:653)
    at rocks.xmpp.core.session.XmppClient.send(XmppClient.java:467)
    at dictionary.bot.Bot.lambda$null$1(Bot.java:77)
    at rx.Observable$31.onNext(Observable.java:7139)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:130)
    ... 13 more

Jan 24, 2016 10:27:14 AM rocks.xmpp.util.XmppUtils lambda$notifyEventListeners$3
WARNING: Session is not connected to server
rx.exceptions.OnErrorNotImplementedException: Session is not connected to server
    at rx.Observable$31.onError(Observable.java:7134)
    at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:154)
    at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:137)
    at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:41)
    at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:30)
    at rx.Observable.subscribe(Observable.java:7393)
    at rx.Observable.subscribe(Observable.java:7125)
    at dictionary.bot.Bot.lambda$initializeConnection$2(Bot.java:77)
    at rocks.xmpp.util.XmppUtils.lambda$notifyEventListeners$3(XmppUtils.java:191)
    at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:890)
    at java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:404)
    at rocks.xmpp.util.XmppUtils.notifyEventListeners(XmppUtils.java:189)
    at rocks.xmpp.core.session.XmppSession.lambda$handleElement$9(XmppSession.java:827)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Session is not connected to server
    at rocks.xmpp.core.session.XmppSession.send(XmppSession.java:653)
    at rocks.xmpp.core.session.XmppClient.send(XmppClient.java:467)
    at dictionary.bot.Bot.lambda$null$1(Bot.java:77)
    at rx.Observable$31.onNext(Observable.java:7139)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:130)
    ... 13 more

PS - Strangely this issue is not reproduced when I am using intellij. Can be that intellij is picking up some other version. Here is a sample - https://github.com/DrawersApp/Java-Bot

Comments (10)

  1. Christian Schudt repo owner

    Hi,

    not sure, why this is happening. I've never seen this, even when not using IntelliJ (i.e. when using a built client). I've included the erroneous status in the exception message (9f453b7).

    I've also uploaded a 0.7.0-SNAPSHOT version to OSS snapshot repository: https://oss.sonatype.org/content/repositories/snapshots/

    If you are still interested in finding a solution, could you please try that version? (Although I saw, you are trying Smack now).

    Alternatively you could try:

    xmppClient.addSessionStatusListener(status -> {
        System.out.println(status);
    });
    

    in order to find out, what is causing a status change.

  2. Harshit Bangar reporter

    Thanks for such a quick response. I will give it a try. The issue also came even with intellij build. When I am running it in ide the keep alives are fine. But when the same thing I ran on command line the outgoing messages and keep alive are not working.

    Smack is working fine so doesn't look like a maven issue. Just give me a day or two I will try these changes and revert back. I can also commit an echobot jar if you want to try it out yourself.

  3. Harshit Bangar reporter

    Hey, Sorry got busy with some important stuff. Will took it as first thing tomorrow.

  4. Harshit Bangar reporter

    Hey. I tried but I am still getting the same error. May be my packaging is not correct? I am trying to debug it and see if something is wrong locally.

  5. Christian Schudt repo owner

    You could try this, to see at least a little bit of information.

    xmppClient.addSessionStatusListener(status -> {
        System.out.println(status);
    });
    

    Or set a breakpoint in XmppSession.notifyException

    Maybe you have a similar issue as in issue #69 (That for some reason, some classes cannot be found on the classpath, but that should not occur, if you use the provided Maven jars).

  6. Christian Schudt repo owner

    FYI: I tried your code and successfully logged in using your test credentials and successfully send multiple messages with JSON extension (to myself)... Really weird.

  7. Harshit Bangar reporter

    Strange. May be something is wrong. I can close the issue and investigate it offline. Must be something wrong on my side.

  8. Christian Schudt repo owner

    I've released a beta version of 0.7.0 to Maven Central: 0.7.0-beta-1. It likely won't solve your problem, but I've attached the last exception as cause to the IllegalStateException. Maybe that helps, too. Otherwise only debugging can help or the addSessionStatusListener.

  9. Christian Schudt repo owner

    Closing this issue, haven't got any feedback. You can try version 0.7.0 and report back and maybe create a new issue.

  10. Log in to comment