Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.baasbox.android.BaasIOException: java.net.SocketTimeoutException #35

Open
dirkam opened this issue Feb 27, 2015 · 7 comments
Open

Comments

@dirkam
Copy link

dirkam commented Feb 27, 2015

0.9.1 Server with 0.9.2 SDK
How should I handle SocketTimeoutException?

If I call a plugin endpoint

try {
BaasBox box = BaasBox.getDefault();
            box.rest(HttpRequest.POST,
                    "plugin/my.plugin",
                    new JsonObject().put("", ""),
                    true,
                    new BaasHandler<JsonObject>() {
                        @Override
                        public void handle(BaasResult<JsonObject> res) {

                        }
                    });
        }  catch (Exception ex) {
ex.printStackTrace(); }

then I can catch SocketTimeoutException and handle it, but if I use some of the native calls:

try {
BaasDocument.fetchAll(“mycollection”,
    new BaasHandler<List<BaasDocument>>() {
    @Override
        public void handle(BaasResult<List<BaasDocument>> res) {

                        }
                    });
        }  catch (Exception ex) {
ex.printStackTrace(); }

then it crashes with SocketTimeoutException

@eliantor
Copy link
Member

Sorry for this!

Timeouts should not bubble out of the callback, in any case, I'll fix this asap

@dirkam
Copy link
Author

dirkam commented Feb 27, 2015

Thanks!
Can you please also take a look at #32?

@eliantor
Copy link
Member

Also in the mean time you can set a global ExceptionHandler in BaasBox.builder()

@eliantor
Copy link
Member

Hi,

I've executed a simple test, setting the timeout to 1ms:

BaasUser.withUserName(UUID.randomUUID().toString())
                 .setPassword(UUID.randomUUID().toString())
                .signup(new BaasHandler<BaasUser>() {
                            @Override
                            public void handle(BaasResult<BaasUser> result) {
                                if (result.isFailed()) {
                                    Log.d("TAG","ERROR",result.error());
                                }

                            }
                        });

This seems to behave correctly, infact it gives BaasBoxIOException with cause
SocketTimeoutException.

@eliantor
Copy link
Member

Also it works the same for BaasBox.rest(....) that currently is deprecated and for it's replacement BaasBox.rest().async(....).

@dirkam
Copy link
Author

dirkam commented Feb 27, 2015

BaasBox.rest() is fine indeed, however, fetchAll still crashes for me

@dirkam
Copy link
Author

dirkam commented Mar 4, 2015

Could you please check fetchAll as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants