(a) Smack returned “service-unavailable (503)” error at login ()… here is a solution to the problem.
(a) Smack returned “service-unavailable (503)” error at login ()
I’m trying to implement a simple jabber messenger on Android using the asmack library. Here is the code:
public boolean login()
{
if (connection != null && connection.isConnected())
{
Log.i("XMPP", connection.getHost());
try
{
connection.login(USERNAME, PASSWORD);
}
catch (XMPPException e)
{
e.printStackTrace();
return false;
}
return true;
}
return false;
}
The exception I got after connection.login() (the connection looks fine):
service-unavailable(503)
at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:77)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:239)
at org.jivesoftware.smack.Connection.login(Connection.java:353)
at com.someapp.networking.XMPPMessenger.login(XMPPMessenger.java:60)
at com.someapp.XMPPService.onCreate(XMPPService.java:33)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2780)
at android.app.ActivityThread.access$3200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1917)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
What could be the error?
Best Solution
Asmack is able to establish a new connection to the server, but it belongs to Non-SASL mode for some reason (call NonSASLAuthentication.authenticate(NonSASLAuthentication.java:77)
).
I think that’s what the server is trying to tell you with a “service-unavailable(503)” response, i.e. it doesn’t support non-SASL authentication.
Try debugging why smack does not attempt SASL authentication.
Note: The lines in the smack source code viewer are a bit off track because of the deviation from different versions and patches from asmack.