private static final String DOMAIN = "61.153.189.64:8022";
private static final String HOST = "61.153.189.64";
private static final int PORT = 8022;
private String userName ="admin";
private String passWord = "admin";
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword(userName, passWord)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setXmppDomain(JidCreate.domainBareFrom(DOMAIN))
.setHost(HOST)
.setPort(PORT)
.setConnectTimeout(100000)
.setCompressionEnabled(false)
.setHostAddress(InetAddress.getByName(HOST))
.setDebuggerEnabled(true)
.build();
AbstractXMPPConnection conn = new XMPPTCPConnection(config);
conn.connect();
conn.login(userName,passWord);
implementation files('libs/smack-android-4.2.4.jar')
implementation files('libs/smack-android-extensions-4.2.4.jar')
implementation files('libs/smack-core-4.2.4.jar')
implementation files('libs/smack-extensions-4.2.4.jar')
implementation files('libs/smack-im-4.2.4.jar')
implementation files('libs/smack-resolver-minidns-4.2.4.jar')
implementation files('libs/smack-sasl-provided-4.2.4.jar')
implementation files('libs/smack-tcp-4.2.4.jar')
implementation files('libs/xpp3-1.1.4c.jar')
implementation files('libs/org.xbill.dns_2.1.6.jar')
implementation files('libs/jxmpp-core-0.4.1.jar')
implementation files('libs/jxmpp-util-cache-0.4.1.jar')
api 'de.measite.minidns:minidns-hla:0.2.4'
implementation files('libs/jxmpp-jid-0.4.1.jar')
错误信息
07-13 06:09:37.025 18543-18667/com.som.chatxmpp I/xmppConnect: org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). While waiting for establishing TLS
07-13 06:09:37.027 18543-18669/com.som.chatxmpp W/AbstractXMPPConnection: Connection XMPPTCPConnectionnot-authenticated closed with error
org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT HTTP/1.1 400 Bad...@8:1 in org.jivesoftware.smack.util.ObservableReader@3d8b3bb)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:432)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1248)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:1000)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1016)
at java.lang.Thread.run(Thread.java:761)
07-13 06:09:32.025 18543-18668/com.som.chatxmpp D/SMACK: SENT (1): <stream:stream xmlns='jabber:client' to='61.153.189.64:8222' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='admin@61.153.189.64:8222' xml:lang='en'>
07-13 06:09:32.070 18543-18669/com.som.chatxmpp D/SMACK: RECV (1): HTTP/1.1 400 Bad Request
Server: nginx/1.10.3
Date: Fri, 13 Jul 2018 06:08:11 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 173
Connection: close
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.10.3</center>
</body>
</html>