Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SocketTimeoutException: Read timed out, how to fix it?

I have a swing application that read HTML pages using the following command

String urlzip = null;
try {
        Document doc = Jsoup.connect(url).get();
        Elements links = doc.select("a[href]");
        for (Element link : links) {
            if (link.attr("abs:href").contains("BcfiHtm.zip")) {
                urlzip = link.attr("abs:href").toString();
            }
        }
    } catch (IOException e) {
        textAreaStatus.append("Failed to get new file from internet:"+e.getMessage()+"\n");
        e.printStackTrace();
    }
return urlzip;

then my swing application will return a string, It works fine and it reads any HTML page that I give to it. However, some times the application gave me the following error type Exception report. How can i increase timeOut?

like image 346
itro Avatar asked Dec 31 '25 16:12

itro


1 Answers

There's an example on this page.

Jsoup.connect("http://example.com").timeout(3000)
like image 139
Vadim Avatar answered Jan 02 '26 08:01

Vadim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!