如何减少HTTP请求超时通过odata4j发 [英] How to reduce the timeout of HTTP requests send by odata4j

查看:204
本文介绍了如何减少HTTP请求超时通过odata4j发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用odata4j库在移动Android应用程序。有时因为设备失去了它只是发送请求后,移动连接的HTTP请求没有得到响应。经过几次尝试重现和时间吧,我注意到它需要约占27分钟,库抛出产生java.net.SocketException:连接超时。有什么办法来减少此超时,所以我可以照顾,更快速地处理故障?谢谢你。

I'm trying to use the odata4j library in a mobile Android app. Sometimes a HTTP request doesn't get a response because the device lost it's mobile connection just after sending the request. After a few attempts to reproduce it and timing it, I noticed it takes roughly 27 minutes for the library to throw a "java.net.SocketException: Connection timed out". Is there any way to reduce this timeout, so I can take care and handle the failure more quickly? Thanks.

推荐答案

使用的球衣消费者实现(这是默认值)。添加JerseyClientBehavior [1]当你构建你的消费。这使您可以修改ClientConfig [2] - 你可以同时修改连接+读取超时

Use the jersey consumer implementation (which is the default). Add a JerseyClientBehavior [1] when you construct your consumer. This allows you to modify the ClientConfig [2] - you can modify both the connect + read timeout.

[1] <一个href=\"http://$c$c.google.com/p/odata4j/source/browse/odata4j-jersey/src/main/java/org/odata4j/jersey/consumer/behaviors/JerseyClientBehavior.java\" rel=\"nofollow\">http://$c$c.google.com/p/odata4j/source/browse/odata4j-jersey/src/main/java/org/odata4j/jersey/consumer/behaviors/JerseyClientBehavior.java

[2] <一个href=\"http://jersey.java.net/nonav/apidocs/1.1.5.1/jersey/com/sun/jersey/api/client/config/ClientConfig.html\" rel=\"nofollow\">http://jersey.java.net/nonav/apidocs/1.1.5.1/jersey/com/sun/jersey/api/client/config/ClientConfig.html

这篇关于如何减少HTTP请求超时通过odata4j发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆