Crashes Upon Sending XHTML Message

Issue #101 closed
Nishant Mondkar created an issue

As soon as this XHTML message is sent, the session / connection disconnects and attempts to reconnect. No Exception or warning alert is generated.

Normal (plain text) messages work just fine.

omsg = "<p>Hi</p>";
Message m = new Message(from, Type.CHAT, "Hi");

Html xhtml = new Html(omsg);
m.addExtension(xhtml);
//log.info("Sending message " + m.toString());
session.sendMessage(m);
public static TcpConnectionConfiguration connconf = TcpConnectionConfiguration.builder()
            .hostname(<server>)
            .port(5222)
            .hostnameVerifier((h, s) -> true)
            .secure(true)
            //.socketFactory(new DummySSLSocketFactory())
            .sslContext(sslContext)
            .build();

public static XmppSessionConfiguration sessconf = XmppSessionConfiguration.builder()
            //.debugger(VisualDebugger.class)
            .build();
session = XmppClient.create(<domain>, sessconf, connconf);

rosterer = session.getManager(RosterManager.class);
presencer = session.getManager(PresenceManager.class);
filer = session.getManager(FileTransferManager.class);

session.addInboundPresenceListener(e -> {
    Presence presence = e.getPresence();
    if (presence.getType() == Presence.Type.SUBSCRIBE) {
        presencer.approveSubscription(presence.getFrom());
    }
});

session.addInboundMessageListener(e -> {
    if (e.getMessage().getBody() != null)
        executorService.execute(new MP(e));
});         

//filer.addFileTransferOfferListener(e -> executorService.execute(new FP(e)));

session.enableFeature(Html.NAMESPACE);
session.enableFeature("http://www.w3.org/1999/xhtml");
session.enableFeature(Socks5ByteStreamManager.class);
session.disableFeature(InBandByteStreamManager.class);

session.connect();
session.login(<userid>, <password>, <resource>);

Comments (3)

  1. Christian Schudt repo owner

    You are right. The issue is, that the Html class is not in the default JAXB context. I will fix it.

    As a workaround add the extension manually:

    XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
        .extensions(Extension.of(Html.NAMESPACE, true, Html.class))
        .build();
    

    This will enable the "HTML" feature also for service discovery and adds Html.class to the default JAXBContext.

  2. Log in to comment