We're using Solr 6.6.6, with SolrJ 7.7.1.

We've started on supporting use of Basic Authentication with Solr, so we need 
to include credentials when connecting and sending requests.  It's clear that 
we can include the credentials in each SolrRequest.  However, we are not always 
building individual requests, but using many of the helper methods of 
CloudSolrClient inherited from SolrClient (e.g. add, deleteById, deleteByQuery, 
etc.).

However, I'm not able to even get a CloudSolrClient instance built, because I 
cannot find a way to provide the credentials for the builder to use, which I 
seem to need when using Solr urls instead of Zookeeper connection to build the 
client.

This is a snippet of what I'm doing:

CloudSolrClient.Builder builder = new CloudSolrClient.Builder(solrUrls);
builder.withParallelUpdates(true);
CloudSolrClient solrServer = builder.build();

builder.build() throws an exception, that authentication is required.

Caused by: 
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error 
from server at http://localhost:8983/solr: Expected mime type 
application/octet-stream but got text/html. <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 401 require authentication</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /solr/admin/collections. Reason:
<pre>    require authentication</pre></p>
</body>
</html>

Stepping through it, exception is coming from:

stateProvider = new HttpClusterStateProvider(solrUrls, httpClient);

Searching the web, I've seen several possible solutions, all of which seem 
clumsy (creating custom HttpClients and/or LBHttpSolrClients), and in one case, 
using a global CredentialsProvider, will not work in our case, as we have 
support in our product to use several distinct SolrCloud clusters, each of 
which may have different credentials.  For something so fundamental, it seems 
awfully difficult.  Are these the only ways to use support authentication?  As 
mentioned above, we are not always building SolrRequest structures directly, so 
would be optimal to have the client connections include the credentials 
automatically.

Thank you for your assistance.
Jerry





[Nastel  Technologies]<http://www.nastel.com/>

The information contained in this e-mail and in any attachment is confidential 
and
is intended solely for the use of the individual or entity to which it is 
addressed.
Access, copying, disclosure or use of such information by anyone else is 
unauthorized.
If you are not the intended recipient, please delete the e-mail and refrain 
from use of such information.

Reply via email to