我在网络应用中使用smack 3.2.2
将邮件从一个Gmail ID发送到另一个。我的应用程序在我的本地主机(localhost:8080 / app)中工作正常,但当我把它放在远程服务器(www.example.com:8080/App)时,它显示我connection.getUser()
为空且login fail because of username and password is incorrect
。但如果用户名和密码不正确,它怎么能在我的localhost中工作?它也抛出
org.jivesoftware.smack.sasl.SASLErrorException:使用PLAIN的SASLError: 未授权的
异常。相同的代码在localhost中有效,但在远程服务器中无效。
connConfig = new ConnectionConfiguration(“talk.google.com”,5222, “gmail.com”); connection = new XMPPConnection(connConfig); connection.connect();
connConfig.setSASLAuthenticationEnabled(假); SASLAuthentication.supportSASLMechanism(“PLAIN”,0);
connection.login(用户名,密码);
并且还得到了
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.ServiceDiscoveryManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.XHTMLManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.muc.MultiUserChat
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.filetransfer.FileTransferManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.LastActivityManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.commands.AdHocCommandManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.ServiceDiscoveryManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.XHTMLManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.muc.MultiUserChat
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.filetransfer.FileTransferManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.LastActivityManager
Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.commands.AdHocCommandManager
forbidden(403) Username or password not correct.
at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:109)