简体   繁体   English

如何更改Java ROME解析器的默认套接字超时?

[英]How to change Java ROME parser default socket timeout?

I am parsing a fair amount of RSS feeds in cascade using Java ROME as my XML parser. 我正在使用Java ROME作为我的XML解析器来级联解析相当数量的RSS源。 Sometimes one of the RSS feeds might be unreachable because of network issues, which results in a Socket timeout when trying to create the XMLReader object ( new XMLReader(url)). 有时,由于网络问题,其中一个RSS源可能无法访问,这会在尝试创建XMLReader对象(新的XMLReader(url))时导致Socket超时。

The problem is that the default timeout lasts about 2 decades and when it happens it's slowing down the whole process. 问题是默认超时持续大约20年,当它发生时,它会减慢整个过程。

Is there a way to change the default socket timeout in Java ROME? 有没有办法在Java ROME中更改默认套接字超时?

When you create XMLReader object ( new XMLReader(url)) , you already have a URLConnection object which is passed as the argument for XMLReader . 创建XMLReader object ( new XMLReader(url)) ,您已经有一个URLConnection对象,该对象作为XMLReader的参数传递。 Call, setConnectTimeout(long) of URLConnection and set your timeout value. 调用URLConnection的setConnectTimeout(long)并设置超时值。 I dont think Rome provides any connection timeout options 我不认为罗马提供任何连接超时选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM