-->

Groovy的RESTClient实现有很多连接(Groovy RestClient with ma

2019-10-18 12:17发布

使用Groovy RESTClient实现我收到以下异常:

    java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.

据我了解的一个连接没有发布,所以我不能再拍一张。

什么是可能的解决方案?

结交新RESTClient实现为每个电话吗? 或者,也许有一些池?

谢谢!

Answer 1:

默认情况下,REST客户端使用只处理一次一个连接BasicClientConnManager。 为了做到并发连接,你需要使用AsyncHTTPBuilder:

def httpClient = new AsyncHTTPBuilder(
        poolSize: 20,
        uri: 'https://www.mysite.com'
)


文章来源: Groovy RestClient with many connections