Skip to content

Increasing the timeout to prevent socket timeout error #90

Open

Description

@rbgpt

I am facing socket timeout exception whenever I am trying to upload a little large image or some file through android. How can I increase timeout to prevent socket timeout exception?

Activity

  1. fvumbaca commented on Mar 22, 2016

    @fvumbaca

    Hi @robinskumar73! I had the same problem.

    The cleanest way I found to increase the timeout of the socket was to extend the com.strongloop.android.loopback.RestAdapter class and add the method:

    public void setTimeout(int timeoutMillis) {
        getClient().setTimeout(timeoutMillis);
    }

    What i use is something like:

    public class MyRestAdapter extends com.strongloop.android.loopback.RestAdapter{
        public static final int TIMEOUT = 30000;
        public MyRestAdapter(Context context, String url) {
            super(context, url);
            setTimeout(TIMEOUT); // Default to the desired timeout
        }
        // And the method above
    }

    And finally use this child class in place of the old RestAdapter class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions