Jim
Jim

Reputation: 19582

Why do I get a socket time out?

I am trying to access a remote service via Volley and I end up in the on error response function with the error:

02-26 10:29:53.491: D/MyApp(1592): java.net.SocketTimeoutException: failed to connect to 10.10.201.10 (port 443) after 5000ms

I can access this IP from my browser and I can see the interface fine. Why do I get this from eclipse/volley? How can I debug this?

Upvotes: 0

Views: 547

Answers (3)

DoubleK
DoubleK

Reputation: 562

Does your server return any kind of data, SocketTimeoutException occurr when there are blocking issues in read() or accept(), ie. if server doesn't return any data in defined timeout interval this exception will rise. It also could be a network problem, delay of some kind.

Upvotes: 0

Faruk Yazici
Faruk Yazici

Reputation: 2404

  1. What is the response time when you access it from browser? Is it shorter that that it takes in Eclipse?
  2. If you know the average response time, you can increase timeout duration in Eclipse. Whatever library you use, there must be some method like setTimeout(int millis). There are not further things you can do unless you dig into the service codes.

Upvotes: 1

Abhishek V
Abhishek V

Reputation: 12536

Did you set socket timeout value as 5000ms? If so, the request is failing since it is taking more than 5000ms. Try increasing the time out value in your custom Request class

public static final int MY_SOCKET_TIMEOUT_MS = 30000;

@Override
    public Request<?> setRetryPolicy(RetryPolicy retryPolicy) {
        retryPolicy = new DefaultRetryPolicy(MY_SOCKET_TIMEOUT_MS,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES , DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);

        return super.setRetryPolicy(retryPolicy);
    }

Upvotes: 1

Related Questions