문제

Using Groovy RestClient I am getting the following exception:

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

As I understand that one connection has not released, so I cannot make another one.

What are the possible solutions?

Make new RestClient for every call? Or maybe there is some pool?

Thanks!

도움이 되었습니까?

해결책

By default the REST Client uses the BasicClientConnManager which only handles one connection at one time. In order to do concurrent connections, you need to use the AsyncHTTPBuilder:

def httpClient = new AsyncHTTPBuilder(
        poolSize: 20,
        uri: 'https://www.mysite.com'
)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top