isValidLogin() returns BackendlessFault

I have ported my App to Backendless 4 and I receive the following error almost everytime I try to call validLogin() method (below) from my onCreate MAIN class:
"BackendlessFault{ code: ‘Internal client exception’, message: ‘http://192.168.178.31:80/api/APP_ID/ANDROID_KEY/binary’ }

Is it a beta version bug or am I doing something wrong?

private void validLogin() {
Backendless.UserService.isValidLogin(new AsyncCallback<Boolean>() {
@Override
public void handleResponse(Boolean isValidLogin) {
if( isValidLogin && Backendless.UserService.CurrentUser() == null ) {
String currentUserId = Backendless.UserService.loggedInUser();
if (!currentUserId.equals("")) {
Backendless.UserService.findById(currentUserId, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser currentUser) {
Backendless.UserService.setCurrentUser( currentUser );
startActivity( new Intent( Main.this, MyEventListActivity.class ) );
finish();
}
@Override
public void handleFault(BackendlessFault fault) {
String error = String.format("%s, %s, %s", fault.getCode(), fault.getMessage(), fault.getDetail());
Toast.makeText(Main.this, error, Toast.LENGTH_SHORT).show();
Log.d(“Main validLogin() “, error);
}
});
}
}
}
@Override
public void handleFault(BackendlessFault fault) {
String error = String.format(”%s, %s, %s”, fault.getCode(), fault.getMessage(), fault.getDetail());
Toast.makeText(Main.this, error, Toast.LENGTH_SHORT).show();
Log.d("Main validLogin() ", error);
}
});
}

Hi Jure,

Does such problem appear only when you use the method Backendless.UserService.isValidLogin or any Backendless methods?
And what did you mean when wrote ‘almost everytime’. Does it work sometimes?

And finally, (maybe it’ll be funny for you but I have to ask it). You provide the next error message in this topic: ‘http://192.168.178.31:80/api/APP_ID/ANDROID_KEY/binary’.
Did you replace your app id and android key by those placeholders (APP_ID, ANDROID_KEY) before posting it to the support forum or it is error message without any correction?

Regards Ilya

Hi Ilya!
Actually I am not sure if the error appears in other parts, but the rest of the app is functioning well. I have seen a similar error every now and then though. But here with this function it is far too regular. I need to login again 80% of the time.
And yes… I did replace those things (ID and KEY) :slight_smile:

Aha! Received the same error just login in!

BackendlessFault{ code: ‘Internal client exception’, message: ‘http://192.168.178.31:80/api/[...]/binary’ }

Hi Jure,

The cause of this problem is sill unclear.
Could you please do next:

  1. go to section ‘Code Generation’ in the Console
  2. download the sample android app ‘Registration and Login’
  3. run this app and check if it work properly (login, logout, registration)

Also, please make sure you use 4 version of Android-SDK in your project.

Regards Ilya

Ilya!

This is working very well, I only received the same error one time, when switching the start from “run” to “debug” mode in Android studio (Shift-F10 versus Shift-F9).
All the rest is started smoothly and when using “Remember me” it worked with no exception as well!
And yes, I am using version 4 all the time.

I have now changed the few lines just a little (copying the created sample almost exactly. Previous code is in comment above, the new is added below) to this:

 private void validLogin() {
 // Backendless.UserService.isValidLogin(new AsyncCallback&lt;Boolean&gt;() {
 Backendless.UserService.isValidLogin(new DefaultCallback&lt;Boolean&gt;( this )
 {
 @Override
 public void handleResponse(Boolean isValidLogin)
 {
 if( isValidLogin && Backendless.UserService.CurrentUser() == null )
 {
 String currentUserId = Backendless.UserService.loggedInUser();
 



 if (!currentUserId.equals(""))
 {
 



 //Backendless.UserService.findById(currentUserId, new AsyncCallback&lt;BackendlessUser&gt;()
 Backendless.UserService.findById( currentUserId, new DefaultCallback&lt;BackendlessUser&gt;( Main.this, "Logging in..." )
 {
 @Override
 public void handleResponse(BackendlessUser currentUser)
 {
 super.handleResponse( currentUser );
 Backendless.UserService.setCurrentUser( currentUser );
 



 // set the 4 Global static variables
 Global.setGlobals(currentUser);
 



 if (Global.gIsCurrentUserEventOrganiser == Boolean.TRUE)
 startActivity( new Intent( Main.this, MyEventListActivity.class ) );
 else
 startActivity( new Intent( Main.this, EventListActivity.class ) );
 



 finish();
 }
// REMOVED THIS
/* @Override
 public void handleFault(BackendlessFault fault) {
 String error = String.format("%s, %s, %s", fault.getCode(), fault.getMessage(), fault.getDetail());
 Toast.makeText(Main.this, error, Toast.LENGTH_SHORT).show();
 Log.d("Main validLogin() ", error);
 }*/
 });
 }
 }
 



 super.handleResponse( isValidLogin ); //I ADDED THIS LINE AS WELL
 }
 



// REMOVED THIS
/* @Override
 public void handleFault(BackendlessFault fault) {
 String error = String.format("%s, %s, %s", fault.getCode(), fault.getMessage(), fault.getDetail());
 Toast.makeText(Main.this, error, Toast.LENGTH_SHORT).show();
 Log.d("Main validLogin() ", error);
 }*/
 });
 }

and it looks like it is now running smoothly! I have no idea what is actually changed. But it looks like it’s working now. Or am I just lucky currently and the error will return as soon as we close this as “SOLVED” :smiley:
But if it is really working, I am very grateful to you! Hopefully I can bother wilt a few similar questions in the future :wink:
One more thing: Backendless 4 looks really good and I have successfully ported my app to it. I can’t wait for Backendless to officially release it on its own server!

Hi Jure,
I’m glad to hear that your issue was resolved.
Regarding release of Backendless 4, we are looking forward to it too))

Regards Ilya