[ 
https://issues.apache.org/jira/browse/SOLR-6239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14959063#comment-14959063
 ] 

Shawn Heisey commented on SOLR-6239:
------------------------------------

I scratched my head trying to figure out how you can fix this.  
DefaultHttpClient is deprecated and shouldn't be used if you can avoid it.

Perhaps you can upgrade the jars for HttpClient and friends in your SolrJ app 
and try code similar to the following to create your HttpClient object with the 
authentication parameters:

{code}
        String username = "user";
        String password = "password";
        CredentialsProvider provider = new BasicCredentialsProvider();
        AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, 
AuthScope.ANY_REALM);
        UsernamePasswordCredentials credentials = new 
UsernamePasswordCredentials(username, password);
        provider.setCredentials(scope, credentials);
        
        RequestConfig rc = RequestConfig.custom()
                .setConnectTimeout(15000)
                .setSocketTimeout(Const.SOCKET_TIMEOUT)
                .build();
        HttpClient httpClient = HttpClients.custom()
                .setDefaultRequestConfig(rc)
                .setMaxConnPerRoute(300)
                .setMaxConnTotal(5000)
                .setDefaultCredentialsProvider(provider)
                .disableAutomaticRetries()
                .build();
{code}

FYI -- you can use the latest httpclient, httpmime, and httpcore jars as 
drop-in replacements in your application and they will work, even with older 
SolrJ versions.  The httpcomponents project has done an excellent job of not 
breaking the APIs with new minor releases.

> HttpSolrServer: connection still allocated
> ------------------------------------------
>
>                 Key: SOLR-6239
>                 URL: https://issues.apache.org/jira/browse/SOLR-6239
>             Project: Solr
>          Issue Type: Bug
>          Components: clients - java
>    Affects Versions: 4.9
>            Reporter: Sergio Fernández
>            Priority: Minor
>
> In scenarios where concurrency is aggressive, this exception could easily 
> appear:
> {quote}
> org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Invalid 
> use of BasicClientConnManager: connection still allocated.
> Make sure to release the connection before allocating another one.
>       at 
> org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:554)
>  ~[solr-solrj-4.9.0.jar:4.9.0 1604085 - rmuir - 2014-06-20 06:34:04]
>       at 
> org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
>  ~[solr-solrj-4.9.0.jar:4.9.0 1604085 - rmuir - 2014-06-20 06:34:04]
>       at 
> org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
>  ~[solr-solrj-4.9.0.jar:4.9.0 1604085 - rmuir - 2014-06-20 06:34:04]
>       at 
> org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
>  ~[solr-solrj-4.9.0.jar:4.9.0 1604085 - rmuir - 2014-06-20 06:34:04]
>       at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:116) 
> ~[solr-solrj-4.9.0.jar:4.9.0 1604085 - rmuir - 2014-06-20 06:34:04]
>       at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:102) 
> ~[solr-solrj-4.9.0.jar:4.9.0 1604085 - rmuir - 2014-06-20 06:34:04]
> {quote}
> I wonder if there is any solution for it?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to