问题
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.
回答1:
Adding Square's OKHTTP library into the libs folder fixed the issue.
回答2:
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 :)
来源:https://stackoverflow.com/questions/17439935/android-retrofit-causes-socket-timeout-exception