Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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)).

The problem is that the default timeout lasts about 2 decades and when it happens it's slowing down the whole process.

Is there a way to change the default socket timeout in Java ROME?

like image 221
Francesco Avatar asked Apr 05 '13 10:04

Francesco


1 Answers

When you create XMLReader object ( new XMLReader(url)), you already have a URLConnection object which is passed as the argument for XMLReader. Call, setConnectTimeout(long) of URLConnection and set your timeout value. I dont think Rome provides any connection timeout options

like image 105
rajesh Avatar answered Oct 11 '22 17:10

rajesh