cannot enable stream management

Issue #164 resolved
Christoph Scholz created an issue

Unfortunately I seem to be unable to enable stream management using babbler 0.8.2. This is the client code I tried:

    public static void main(String[] args) {
        // Create a "main application" thread, which keeps the JVM running.
        Executors.newFixedThreadPool(1).execute(() -> {
            try {
                XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
                        .debugger(ConsoleDebugger.class)
                        .authenticationMechanisms("PLAIN")
                        .build();

                SocketConnectionConfiguration socketConnectionConfiguration = SocketConnectionConfiguration.builder()
                        .hostname("xmpp.mydomain.org") // The hostname.
                        .port(5223) // The XMPP default port.
                        .sslContext(getTrustAllSslContext()) // Use an SSL context, which trusts every server. Only use it for testing!
                        .channelEncryption(ChannelEncryption.DIRECT)
                        .hostnameVerifier((s, sslSession) -> true)
                        .build();

                XmppClient xmppClient = XmppClient.create("mydomain.org", configuration, socketConnectionConfiguration);
                xmppClient.addInboundMessageListener(e -> onMessageReceived(e.getMessage()));
                xmppClient.enableFeature(StreamManagement.NAMESPACE);

                xmppClient.connect();
                xmppClient.login("testuser", "testpass");
                xmppClient.enableFeature(StreamManagement.NAMESPACE);


                SendTask<Message> trackableMessage = xmppClient.sendMessage(new Message(Jid.of("testuser2@mydomain.org"), Message.Type.CHAT, "Hello World! öäü!"));
                trackableMessage.onAcknowledge(message -> System.out.println("Received by server: " + message));

            } catch (XmppException | GeneralSecurityException e) {
                throw new RuntimeException(e);
            }
        });
    }

Result is like that:

OUT (null): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" to="mydomain.org" version="1.0" xml:lang="de-DE">
IN  (9974650222920354814): <?xml version='1.0'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="9974650222920354814" version="1.0" xml:lang="de-DE" from="mydomain.org">
IN  (9974650222920354814): <stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms></stream:features>
OUT (9974650222920354814): <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">xxx</auth>
IN  (9974650222920354814): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
OUT (9974650222920354814): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" to="mydomain.org" version="1.0" xml:lang="de-DE">
IN  (17268390180692473667): <?xml version='1.0'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="17268390180692473667" version="1.0" xml:lang="de-DE" from="mydomain.org">
IN  (17268390180692473667): <stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"><optional></optional></session><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="/uPYvrXxtAa5yoXZtMivQjUJtzY="/><sm xmlns="urn:xmpp:sm:2"/><sm xmlns="urn:xmpp:sm:3"/><ver xmlns="urn:xmpp:features:rosterver"/><csi xmlns="urn:xmpp:csi:0"/></stream:features>
OUT (17268390180692473667): <iq id="d58927df-3a32-43fd-8e8d-9d098bf1cfe4" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/></iq>
IN  (17268390180692473667): <iq id="d58927df-3a32-43fd-8e8d-9d098bf1cfe4" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>testuser@mydomain.org/130473234291349871607586</jid></bind></iq>
OUT (17268390180692473667): <iq id="bb683b12-71b7-4f09-8a7f-d81a30717375" type="get"><query xmlns="jabber:iq:roster" ver="554bfd63109558f526891ca71132c59c3f117035"/></iq>
IN  (17268390180692473667): <iq from="testuser@mydomain.org" id="bb683b12-71b7-4f09-8a7f-d81a30717375" to="testuser@mydomain.org/130473234291349871607586" type="result" xml:lang="de-DE"/>
OUT (17268390180692473667): <presence><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="5oTzv8QBN75AN//rQSO4V/GZkjQ="/><c xmlns="urn:xmpp:caps"><hash xmlns="urn:xmpp:hashes:2" algo="sha-256">OlWsYzO1m+iaGJKMopKc+WyRftg+X92YZyCUJRxXUF8=</hash></c></presence>
OUT (17268390180692473667): <message to="testuser2@mydomain.org" type="chat"><body>Hello World! öäü!</body></message>
IN  (17268390180692473667): <presence from="testuser@mydomain.org/130473234291349871607586" to="testuser@mydomain.org/130473234291349871607586" xml:lang="de-DE"><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="5oTzv8QBN75AN//rQSO4V/GZkjQ="/><c xmlns="urn:xmpp:caps"><hash xmlns="urn:xmpp:hashes:2" algo="sha-256">OlWsYzO1m+iaGJKMopKc+WyRftg+X92YZyCUJRxXUF8=</hash></c><x xmlns="vcard-temp:x:update"/></presence>

Comments (9)

  1. Christian Schudt repo owner

    Sorry for the late response.

    I tried your client code with 0.8.2 and Openfire and it actually works well.

    Do you have any other error stacktrace?

  2. Christoph Scholz reporter

    No Problem. I’m sorry myself, that it took me until today to answer. I tried the above code again with ejabberd’s current version (v21.01) without any success. Stream management with other clients (namely Conversations) seems to work.

    To me it looks as if ejabberd correctly announces stream management but the client does not enable it. Do you have any idea why it is so? Maybe it’s because ejabberd announces support for sm:3 only after auth or because ejabberd also announces support for sm:2? Only guesses unfortunately.

    I have no error stacktrace or such like. Is there anything I can do to dig deeper?

  3. Christian Schudt repo owner

    Unfortunately, I have also no idea yet. I suspected the same things as you however.

    What you could try though:

    1. Try with 0.9.0-SNAPSHOT, there were changes in the stream negotiation process.
    2. Try with another server. if you have the possibility

    I myself will also look into this.

  4. Christian Schudt repo owner

    Oh, wait with suggestion 1). There’s probably an old artifact.

    EDIT: Deployed current version to https://oss.sonatype.org/content/repositories/snapshots.

  5. Christian Schudt repo owner

    I’ve tested this issue with ejabberd-20.04 and Babbler 0.8.2 and with your code snippet and got a successful result:

    The only difference is that I could not establish a direct SSL Connection to port 5223 and used starttls instead. However I tested direct SSL connection against Openfire.

    With 0.9.0-SNAPSHOT everything worked as well.

    OUT (null): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" to="myhost" version="1.0" xml:lang="de-DE">
    IN  (11292060793784790066): <?xml version='1.0'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="11292060793784790066" version="1.0" xml:lang="de-DE" from="myhost">
    IN  (11292060793784790066): <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls></stream:features>
    OUT (11292060793784790066): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
    IN  (11292060793784790066): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
    OUT (11292060793784790066): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" to="myhost" version="1.0" xml:lang="de-DE">
    IN  (14461844462792365982): <?xml version='1.0'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="14461844462792365982" version="1.0" xml:lang="de-DE" from="myhost">
    IN  (14461844462792365982): <stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms><register xmlns="http://jabber.org/features/iq-register"/></stream:features>
    OUT (14461844462792365982): <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AGFkbWluAGFkbWlu</auth>
    IN  (14461844462792365982): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
    OUT (14461844462792365982): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" to="myhost" version="1.0" xml:lang="de-DE">
    IN  (1302569408953734127): <?xml version='1.0'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="1302569408953734127" version="1.0" xml:lang="de-DE" from="myhost">
    IN  (1302569408953734127): <stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"><optional/></session><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="NqMDrgCx03HLh3URMusgDnNsR30="/><sm xmlns="urn:xmpp:sm:2"/><sm xmlns="urn:xmpp:sm:3"/><ver xmlns="urn:xmpp:features:rosterver"/><csi xmlns="urn:xmpp:csi:0"/></stream:features>
    OUT (1302569408953734127): <iq id="570a2bcc-b723-40a8-824f-cd85c3d5ace0" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/></iq>
    IN  (1302569408953734127): <iq id="570a2bcc-b723-40a8-824f-cd85c3d5ace0" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>admin@myhost/177725618039950591251922</jid></bind></iq>
    OUT (1302569408953734127): <enable xmlns="urn:xmpp:sm:3" resume="true"/>
    IN  (1302569408953734127): <enabled xmlns="urn:xmpp:sm:3" id="g2gCbQAAABgxNzc3MjU2MTgwMzk5NTA1OTEyNTE5MjJoA2IAAAZRYgAMCMBhAg==" resume="true" max="300"/>
    OUT (1302569408953734127): <iq id="a97b8703-55d6-4d2b-9c11-2066375d7da5" type="get"><query xmlns="jabber:iq:roster" ver="5e02d2fb58d78f38abb41ff50450a7a27a4c6712"/></iq>
    IN  (1302569408953734127): <iq from="admin@myhost" id="a97b8703-55d6-4d2b-9c11-2066375d7da5" to="admin@myhost/177725618039950591251922" type="result" xml:lang="de-DE"/>
    IN  (1302569408953734127): <r xmlns="urn:xmpp:sm:3"/>
    OUT (1302569408953734127): <a xmlns="urn:xmpp:sm:3" h="0"/>
    

  6. Christoph Scholz reporter

    That’s interesting. I tried it again with ejabberd 21.04 works with SNAPSHOT. Doesn’t work with 0.8.2. Tried DIRECT_TLS and STARTTLS . No difference.

  7. Log in to comment