K K
K K

Reputation: 101

Android Retrofit Causes Socket Timeout Exception

I am making a POST call to a tomcat server running Struts2 using the retrofit library on an Android Galaxy S3 (/Nexus 7) device. The POST call fails. The tomcat log shows Socket timeout exception.

The same POST using the exact same headers done via curl does not have any issues. I verified that the data on the wire matches using charles proxy.

Any tips/ideas on debugging this issue.

The post call is as follows

@POST(Constants.URL_GET_ORDER_LIST_BASE)
   void getCardOrderList(@Body GetOrderListRequest getOrderListRequest, Callback<GetOrderListResponse> cbGetOrderListResponse);

Please let me know if I need to add more information to explain this better.

Upvotes: 3

Views: 4042

Answers (2)

voghDev
voghDev

Reputation: 5801

I was having SocketTimeoutExceptions too. Pay attention to always add the final slash to your POST call.

Example:

BAD

@POST("/customers")

GOOD

@POST("/customers/")

My mistake was just this :)

Upvotes: 1

K K
K K

Reputation: 101

Adding Square's OKHTTP library into the libs folder fixed the issue.

Upvotes: 2

Related Questions