我可以全局设置HTTP连接的超时时间吗? [英] Can I globally set the timeout of HTTP connections?

查看:402
本文介绍了我可以全局设置HTTP连接的超时时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序使用 javax.xml.ws.Service 来调用由WSDL定义的远程服务。该程序在Google App Engine上运行,默认情况下,该程序将HTTP连接超时设置为 5 秒{1}。我需要增加这个超时值,因为这个服务通常需要很长时间才能响应,但由于这个请求不是用 URLConnection 来完成的,我不知道如何调用 URLConnection.setReadTimeout(int) {2},否则更改超时。

有什么方法可以在App Engine上全局设置HTTP连接超时?而且,为了分享知识,一般人会怎么去解决这类问题?

{1}:https://developers.google.com/appengine/docs/java/urlfetch/overview#Requests



{2}: http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout(int)

sun.net.client.defaultConnectTimeout 和 sun.net.client。 defaultReadTimeout 系统属性记录在此处,例如

  System.setProperty(sun.net.client.defaultReadTimeout,30000); 
System.setProperty(sun.net.client.defaultConnectTimeout,30000);






编辑 p>

对不起,只需重新阅读并注意到这是在Google App Engine上。我不知道,但鉴于谷歌和甲骨文最近的诉讼关系,我猜测GAE不会运行Oracle JVM。如果有人遇到类似的问题,我会在这里留下。


I have a program that uses javax.xml.ws.Service to call a remote service defined by a WSDL. This program runs on the Google App Engine which, by default, sets the HTTP connection timeout to 5 seconds{1}. I need to increase this timeout value since this service often takes a long time to respond, but since this request is not being made with URLConnection, I cannot figure out how to call URLConnection.setReadTimeout(int){2}, or otherwise change the timeout.

Is there any way to globally set the HTTP connection timeout on the App Engine? And, for purposes of sharing knowledge, how would one go about solving this sort of problem generally?

{1}: https://developers.google.com/appengine/docs/java/urlfetch/overview#Requests

{2}: http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout(int)

解决方案

You could try setting the sun.net.client.defaultConnectTimeout and sun.net.client.defaultReadTimeout system properties documented here, e.g.

System.setProperty("sun.net.client.defaultReadTimeout", "30000");
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");


EDIT

Sorry, just re-read and noticed this is on Google App Engine. I don't know for sure, but given the litigious relationship Google and Oracle have lately, I'm guessing GAE doesn't run the Oracle JVM. I'll leave this here in case someone else runs into a similar problem.

这篇关于我可以全局设置HTTP连接的超时时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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