Backendless Support
 
Solved

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);

}

});

}

Leave a Comment

Comments (6)

photo
1

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

photo
1

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) :)

photo
1

Aha! Received the same error just login in!

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

photo
2

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

photo
1

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:

  1. private void validLogin() {
  2. // Backendless.UserService.isValidLogin(new AsyncCallback<Boolean>() {
  3. Backendless.UserService.isValidLogin(new DefaultCallback<Boolean>( this )
  4. {
  5. @Override
  6. public void handleResponse(Boolean isValidLogin)
  7. {
  8. if( isValidLogin && Backendless.UserService.CurrentUser() == null )
  9. {
  10. String currentUserId = Backendless.UserService.loggedInUser();
  11. if (!currentUserId.equals(""))
  12. {
  13. //Backendless.UserService.findById(currentUserId, new AsyncCallback<BackendlessUser>()
  14. Backendless.UserService.findById( currentUserId, new DefaultCallback<BackendlessUser>( Main.this, "Logging in..." )
  15. {
  16. @Override
  17. public void handleResponse(BackendlessUser currentUser)
  18. {
  19. super.handleResponse( currentUser );
  20. Backendless.UserService.setCurrentUser( currentUser );
  21. // set the 4 Global static variables
  22. Global.setGlobals(currentUser);
  23. if (Global.gIsCurrentUserEventOrganiser == Boolean.TRUE)
  24. startActivity( new Intent( Main.this, MyEventListActivity.class ) );
  25. else
  26. startActivity( new Intent( Main.this, EventListActivity.class ) );
  27. finish();
  28. }
  29. // REMOVED THIS
  30. /* @Override
  31. public void handleFault(BackendlessFault fault) {
  32. String error = String.format("%s, %s, %s", fault.getCode(), fault.getMessage(), fault.getDetail());
  33. Toast.makeText(Main.this, error, Toast.LENGTH_SHORT).show();
  34. Log.d("Main validLogin() ", error);
  35. }*/
  36. });
  37. }
  38. }
  39. super.handleResponse( isValidLogin ); //I ADDED THIS LINE AS WELL
  40. }
  41. // REMOVED THIS
  42. /* @Override
  43. public void handleFault(BackendlessFault fault) {
  44. String error = String.format("%s, %s, %s", fault.getCode(), fault.getMessage(), fault.getDetail());
  45. Toast.makeText(Main.this, error, Toast.LENGTH_SHORT).show();
  46. Log.d("Main validLogin() ", error);
  47. }*/
  48. });
  49. }

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" :D

But if it is really working, I am very grateful to you! Hopefully I can bother wilt a few similar questions in the future ;)

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!

photo
1

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