I´ve got a problem to log in to jabber server using Smack 4.1.1. I am successfully connected to the jabber server, but at the time I try to login, it fails with exception. I googled a lot for days, but it seems that no solution on SO or anywhere else works.
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder(); builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
// builder.setUsernameAndPassword(myUserName,password);
builder.setServiceName(jabberServer);
builder.setHost(jabberServer);
builder.setPort(5222)
builder.setDebuggerEnabled(true);
AbstractXMPPConnection connection = new XMPPTCPConnection(builder.build());
connection.connect();
connection.login(myUserName,password);
//connection.login();
I tried both ways, once with setting username and password to builder and once setting it at login. Nothing works, login allways will fail with the following exception:
SASLErrorException: SASLError using PLAIN: not-authorized
Please note, the rest of stacktrace is not important here, so I don´t post it.
what I´ve tried:
using server and service name jabber.org, also tried with jabber.de
set username for example as simple string userName, also with [email protected] (or @jabber.de)
setDebuggerEnabled(false)
,setCompressionEnabled(false)
,setCompressionEnabled(true)
on mybuilder
.also configure SASL mechanism:
SASLAuthentication.unBlacklistSASLMechanism("PLAIN"); SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
BEFORE connect()
and BEFORE login()
setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
setSecurityMode(ConnectionConfiguration.SecurityMode.required);
setSecurityMode(ConnectionConfiguration.SecurityMode.ifpossible);
all these tries I also commentet out completely.
I have googled a lot, found out that this was a bug on older Smack libraries, but should be fixed in the new Smack release above 4.0 . So I have to assume that this error is not a bug in Smack.
I assumed that this error could come because the account that I use is not registered, so I tried to register new Account before login with smacks AccountManager
. I have set allowEmptyOrNullUserNames()
on my builder()
, but register new account throws service not available exception
, so I just assume, that registration with AccountManager
is not available on jabber.org or jabber,de .
I also exactly followed the documentation steps and the README Guide from Smack:
https://www.igniterealtime.org/builds/smack/docs/latest/documentation/
https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide
Question
- What I am missing?
- Is it still a bug, if yes, how to solve it by myself?
- Must an Account be registered by AccountManager or is this automatically done if the user does not exist at the jabber servers?
- Could somebody guide me to the right direction (code example?) maybe with other free XMPP servers from https://xmpp.org/xmpp-software/servers/?
- I read about using better some nightly builds like smack-SNAPSHOT-2015-06-07 from download on ignite realtime, but how should I integrate a nightly build into my Android Studio project? Using dependencies (if yes how?), using import module?
Is there anybody out there in this whole wide developer-universe who has successfully fixed this issue? I am grateful for any information...
UPDATE
I now just make a try and registered on jabber.de over the internet. Then I used my account to log in via my app and IT WORKS! . So it seems that the problem really is that no account is registered. I saw that registration jabber.org is disabled since 2013 because of some attacks and since this time nothing happened. I assume the service of jabber.org is not available anymore. With jabber.de I now had successfully loged in.
I had registered new account like this:
AccountManager accountManager = AccountManager.getInstance(connection);
Map<String, String> map = new HashMap<String, String>();
map.put("username", myUserName);
map.put("password", myPassword);
map.put("email", myEmail);
accountManager.createAccount(myUserName, myPassword, map);
and another way:
AccountManager accountManager = AccountManager.getInstance(connection);
accountManager.createAccount(myUserName, myPassword);
Both I tried with configuring connection without userName and password by setting allowEmptyOrNullUsernames()
(connection was successfull), but there is service not available exception
thrown.
So, the new question is, how to register successfull new Account? Had I missed something in the configuration for example something like allowing to register an account?
2nd Update
It turns out that the most free servers has disabled In-Band-Registration, because of too many Spam violence. So it is not possible anymore on the most open free xmpp servers. Now the question is, how to register via app with this situation? I read something about web services, would that be a solution?
I had the same execption by two different reasons:
Inside your connection method: