Can you please help me why i am getting this exception?

org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException: IOException 
occurred when talking to server at: 
http://localhost:8983/solr/documents_shard1_replica_n1
      at 
org.apache.solr.client.solrj.impl.CloudSolrClient.getRouteException(CloudSolrClient.java:125)
      at 
org.apache.solr.client.solrj.impl.CloudSolrClient.getRouteException(CloudSolrClient.java:46)
      at 
org.apache.solr.client.solrj.impl.BaseCloudSolrClient.directUpdate(BaseCloudSolrClient.java:581)
      at 
org.apache.solr.client.solrj.impl.BaseCloudSolrClient.sendRequest(BaseCloudSolrClient.java:1076)
      at 
org.apache.solr.client.solrj.impl.BaseCloudSolrClient.requestWithRetryOnStaleState(BaseCloudSolrClient.java:934)
      at 
org.apache.solr.client.solrj.impl.BaseCloudSolrClient.request(BaseCloudSolrClient.java:866)
      at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:214)
      at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:106)
      at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:123)
      at 
com.asite.dih.solr.client.AsiteSolrCloudManager.insert(AsiteSolrCloudManager.java:137)
      at com.asite.dih.helper.IndexHelper.insertInBatch(IndexHelper.java:89)
      at com.asite.dih.util.WorkerThread.call(WorkerThread.java:101)
      at com.asite.dih.util.WorkerThread.call(WorkerThread.java:1)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.solr.client.solrj.SolrServerException: IOException 
occurred when talking to server at: 
http://localhost:8983/solr/documents_shard1_replica_n1
      at 
org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:695)
      at 
org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:266)
      at 
org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:248)
      at 
org.apache.solr.client.solrj.impl.LBSolrClient.doRequest(LBSolrClient.java:369)
      at 
org.apache.solr.client.solrj.impl.LBSolrClient.request(LBSolrClient.java:297)
      at 
org.apache.solr.client.solrj.impl.BaseCloudSolrClient.lambda$directUpdate$0(BaseCloudSolrClient.java:555)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at 
org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:218)
      ... 3 more
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:571)
      ... 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
________________________________
From: Vishal Patel <vishalpatel199...@outlook.com>
Sent: Monday, August 5, 2024 6:51 PM
To: users@solr.apache.org <users@solr.apache.org>
Subject: Getting IOException when used basic authentication on the time of 
indexing in Solr 8.9.0


I have install solr 8.9.0 in cloud mode. I have created 2 shards. I have 
enabled the Basic Authentication using security.json. not use the authorization 
part.
security.json
{
  "authentication":{
    "blockUnknown": true,
    "class":"solr.BasicAuthPlugin",
    "credentials":{"solr":"Y6xFaUPypZOWNmgaU+IkZ8eP4TJxXW50= 
bWtoYjk2Yjhscmx6a2Jveg=="},
    "realm":"My Solr users",
    "forwardCredentials": false
  }
}

Using below command upload security.json in zookeeper
solr zk cp file:D:\Asite_work\Solr_8.9.0\shard1\bin\security.json 
zk:/security.json -z "localhost:12181,localhost:12182"

When I hit http://localhost:8983/solr I got the Basic Authentication page and 
after enter the successful login details it worked properly but when I try to 
index using code I am getting the ERROR
org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException: IOException 
occurred when talking to server at: 
http://localhost:8983/solr/documents_shard1_replica_n1

My index code is below

final List<String> zkServers = new ArrayList<>();
zkServers.add("localhost:12181");
zkServers.add("localhost:12182");
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new 
UsernamePasswordCredentials("solr", "Abc@123");
provider.setCredentials(AuthScope.ANY, credentials);
HttpClient client = 
HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
CloudSolrClient sc = new CloudSolrClient.Builder(zkServers, 
Optional.empty()).withParallelUpdates(true).withHttpClient(client).build();
sc.setDefaultCollection("documents");
sc.connect();
UpdateResponse resp = sc.add(docs, SolrConstants.COMMIT_WITHIN);

Can anyone help me why I am getting this error? Anything's need to configure in 
zookeeper?

Regards,
Vishal

Reply via email to