Проблема с подключением к ejabberd из Android - PullRequest
0 голосов
/ 29 марта 2019

Я использую ejabberd на моем ПК.Когда я пытался подключить его к Android с помощью библиотеки smack, возникла проблема с подключением.

Я использую converse.js для подключения, и он работает отлично.

Код Android показан ниже:


BOSHConfiguration conf = BOSHConfiguration.builder()
                        .setUsernameAndPassword("test@desktop-9ell91c", "12345")
                        .setFile("/http-bind/")
                        .setHost("192.168.225.83")
                        .setPort(5443)
                        .setXmppDomain(JidCreate.domainBareFrom("desktop-9ell91c"))
                        .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                        .build();

                XMPPBOSHConnection connection = new XMPPBOSHConnection(conf);
                connection.connect();
                connection.disconnect();

Конфигурация для ejabberd:

port: 5443
    module: ejabberd_http
    request_handlers:
      "/api": mod_http_api
      "/bosh": mod_bosh
      "/upload": mod_http_upload
      "/ws": ejabberd_http_ws
      "/oauth": ejabberd_oauth
    web_admin: true
    http_bind: true
    captcha: false
    tls: false

При отладке это выглядит так:

2019-03-29 16:34:50.982 3564-3840/com.example.chat D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2019-03-29 16:34:50.989 3564-3840/com.example.chat I/BOSHClient: Starting with 1 request processors
2019-03-29 16:34:51.014 3564-3842/com.example.chat I/System.out: isEmailSend:POST
2019-03-29 16:34:51.014 3564-3842/com.example.chat I/System.out: getAllHeaders:POST
2019-03-29 16:34:51.017 3564-3842/com.example.chat I/System.out: httpHeader:Content-Type: text/xml; charset=utf-8
2019-03-29 16:34:51.121 3564-3843/com.example.chat D/SMACK: RECV (0): <body xmpp:version='1.0' authid='17399078112278266584' xmlns='http://jabber.org/protocol/httpbind' sid='89daf51229fa6259ceb0830dd4f0f10aeee0a237' wait='60' ver='1.11' polling='2' inactivity='30' hold='1' xmpp:restartlogic='true' requests='2' secure='true' maxpause='120' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' from='desktop-9ell91c'><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></body>
2019-03-29 16:34:51.229 3564-3844/com.example.chat I/System.out: isEmailSend:POST
2019-03-29 16:34:51.229 3564-3844/com.example.chat I/System.out: getAllHeaders:POST
2019-03-29 16:34:51.229 3564-3844/com.example.chat I/System.out: httpHeader:Content-Type: text/xml; charset=utf-8
2019-03-29 16:35:21.175 3564-3844/com.example.chat W/AbstractXMPPConnection: Connection XMPPBOSHConnection[not-authenticated] (0) closed with error
    org.igniterealtime.jbosh.BOSHException: Terminal binding condition encountered: remote-stream-error  (Encapsulated transport protocol error.)
        at org.igniterealtime.jbosh.BOSHClient.checkForTerminalBindingConditions(BOSHClient.java:1393)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1169)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727)
        at java.lang.Thread.run(Thread.java:764)
...