lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Bende <bbe...@gmail.com>
Subject Re: Solr6.3.0 SolrJ API for Basic Authentication
Date Tue, 14 Feb 2017 17:01:41 GMT
Hello,

The exception you are getting looks more like you can't connect to the
IP address from where your SolrJ code is running, but not sure.

For the basic credentials, rather than trying to do something with the
http client, you can provide them on the request like this:

QueryRequest req = new QueryRequest(solrQuery);
req.setBasicAuthCredentials(username, password);

The setBasicAuthCredentials method is part of SolrRequest, so any
request that extends it should allow the credentials to be set.

-Bryan


On Tue, Feb 14, 2017 at 6:27 AM, vrindavda <vrindavda@gmail.com> wrote:
> Hello ,
>
> I am trying to connect SolrCloud using SolrJ API using following code :
>
>       String zkHostString = "localhost:9983";
>       String USER = "solr";
>       String PASSWORD = "SolrRocks";
>
>
>       CredentialsProvider credentialsProvider = new
> BasicCredentialsProvider();
>       credentialsProvider.setCredentials(AuthScope.ANY, new
> UsernamePasswordCredentials(USER, PASSWORD));
>       CloseableHttpClient httpClient =
> HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
>
>       CloudSolrClient solr = new
> CloudSolrClient.Builder().withZkHost(zkHostString).withHttpClient(httpClient).build();
>       ((CloudSolrClient)solr).setDefaultCollection("gettingstarted");
>
>
>
>
> But getting Error As :
>
>
> Exception in thread "main"
> org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException:
> IOException occured when talking to server at:
> http://192.168.0.104:8983/solr/gettingstarted_shard2_replica1
>         at
> org.apache.solr.client.solrj.impl.CloudSolrClient.directUpdate(CloudSolrClient.java:767)
>         at
> org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(CloudSolrClient.java:1173)
>         at
> org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:1062)
>         at
> org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:1004)
>         at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
>         at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
>         at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:190)
>         at com.app.graphiti.TextParser.main(TextParser.java:92)
> Caused by: org.apache.solr.client.solrj.SolrServerException: IOException
> occured when talking to server at:
> http://192.168.0.104:8983/solr/gettingstarted_shard2_replica1
>         at
> org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:607)
>         at
> org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:262)
>         at
> org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:251)
>         at
> org.apache.solr.client.solrj.impl.LBHttpSolrClient.doRequest(LBHttpSolrClient.java:435)
>         at
> org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(LBHttpSolrClient.java:387)
>         at
> org.apache.solr.client.solrj.impl.CloudSolrClient.lambda$directUpdate$0(CloudSolrClient.java:742)
>         at java.util.concurrent.FutureTask.run(Unknown Source)
>         at
> org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:229)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>         at java.lang.Thread.run(Unknown Source)
> Caused by: org.apache.http.client.ClientProtocolException
>         at
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
>         at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
>         at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
>         at
> org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:498)
>         ... 10 more
> Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot
> retry request with a non-repeatable request entity.
>         at
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:225)
>         at
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
>         at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
>         at
> org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
>         at
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
>         ... 13 more
> 16:55:40.289 [main-SendThread(0:0:0:0:0:0:0:1:9983)] DEBUG
> org.apache.zookeeper.ClientCnxn - Got ping response for sessionid:
> 0x15a3bc76e1f000e after 1ms
> 16:55:43.624 [main-SendThread(0:0:0:0:0:0:0:1:9983)] DEBUG
> org.apache.zookeeper.ClientCnxn - Got ping response for sessionid:
> 0x15a3bc76e1f000e after 1ms
> 16:55:46.958 [main-SendThread(0:0:0:0:0:0:0:1:9983)] DEBUG
> org.apache.zookeeper.ClientCnxn - Got ping response for sessionid:
> 0x15a3bc76e1f000e after 1ms
> \
>
>
> Please help.
> Vrinda Davda
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr6-3-0-SolrJ-API-for-Basic-Authentication-tp4320238.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message