我正在使用 XMLReader 来简单地阅读如下所示的提要。
URLConnection urlConnection = url.openConnection();
XmlReader reader = new XmlReader(urlConnection);
当它被调用时,我会在 5 秒内收到一个 IOException“Timeout 在获取时”。所以我尝试将超时设置为最大值。(10 秒)但仍然没有运气,并且在 5 秒内仍然是 IOExeption。
urlConnection.setConnectTimeout(10000);
(最大值在文档中说明:http://code.google.com/intl/nl-NL/appengine/docs/java/urlfetch/overview.html)
似乎提要的大小太大了。当我调用较小的提要时 它工作正常。有什么解决方法或解决方案吗?我需要能够调用更大的提要。
最佳答案
您应该使用setReadTimeout
方法来设置读取截止时间:
urlConnection.setReadTimeout(10000); //10 Sec
您应该能够在 10 秒内下载更大的 Feed。
如果您仍然有问题,请尝试摆弄 this不同的方法。
关于java - "Timeout while fetching"URLFetch GAE/J,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4124695/