扩展程序时的套接字超时

时间:2016-07-19 14:10:40

标签: java

所以我有一个使用不同帐户登录网站,检索数据并将数据发送到数据库的程序。

当我使用一个帐户运行程序时,它运行正常,没有错误,并且可以很好地更新数据库。这是一个用户名和密码(粗略地)的样子:

loginsList.put( "firstUsername", "firstPassword" );

for ( Entry<String, String> nextLogin : logins.entrySet() ) {
    String nextUser = nextLogin.getKey();
    String nextPass = nextLogin.getValue();
//login to the website
    Response authenticateUserResponse = Jsoup.connect( WEBSITE_I_NEED_TO_LOGIN_TO )
            .data( "username", nextUser )
            .data( "password", nextPass )
            .execute();
//then it would retrieve some data

retrieve some data

//then it would update the database

repository.save();

然而,只要我将它扩展到100个帐户(即loginsList包含100个用户名和密码),我就得到了

java.net.SocketTimeoutException:读取超时

错误,因为满量程需要2个小时才能运行,这真的很紧张。出现这种情况的原因是什么?我认为,因为它只适用于一个帐户,所以所有的超时应该很好地协调。顺便说一句,如果有任何相关性,我会使用spring-batch。

0 个答案:

没有答案