dromara / dromara/forest

使用代理时,多线程并发问题

Open
#170 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.9k
Forks
241
PR merge metrics
No merged PRs in 30d

Description

版本:1.5.33
问题:多线程下,使用s5代理,发现返回的结果会串。比如5个不同的代理,结果是一样的。

代码:

@Test
void testS5Proxy() {
ExecutorService executorService = ThreadUtil.newExecutor();
List list = AgProxy
.findAll(Sort.descending("createTime"))
.page(0, 100)
.list();
list.stream().forEach(agProxy -> {
executorService.execute(() -> {
validateS5(agProxy);
});
});
try {
executorService.awaitTermination(100, TimeUnit.MINUTES);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

private void validateS5(AgProxy proxyParma) {
ForestResponse forestResponse = Forest.get("http://ip-api.com/json")
.proxy(ForestProxy.socks(proxyParma.getIp(), proxyParma.getPort()).username(proxyParma.getUsername()).password(proxyParma.getPassword()))
.connectTimeout(15000)
.sync()
.maxRetryCount(1)
.executeAsResponse();
String resStr = forestResponse.get(String.class);
log.info(resStr + proxyParma.toString());
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.