You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Preeti Bhat <pr...@shoregrp.com> on 2016/09/28 13:43:59 UTC

Connect to SolrCloud using proxy in SolrJ

Hi All,

I am trying to connect to the Solrcloud using the zookeeper host string in my java application(CloudSolrClient). I am able to connect to the solrcloud when there are no proxy settings needed, but when trying to connect to the code using proxy settings, I am getting the below error.


1)      Without Proxy

System.setProperty("javax.net.ssl.keyStore", keyStore);

System.setProperty("javax.net.ssl.keyStorePassword", keyStorePsswd);

System.setProperty("javax.net.ssl.trustStore", trustStore);

System.setProperty("javax.net.ssl.trustStorePassword", trustStorePsswd);


HttpClientBuilder builder = HttpClientBuilder.create();
       builder.useSystemProperties();
       CloseableHttpClient httpclient = builder.build();
cloud_client = new CloudSolrClient(zkHost, httpclient);
@SuppressWarnings("rawtypes")
SolrRequest req = new QueryRequest();
req.setBasicAuthCredentials(UserName, Password);
       cloud_client.request(req, collectionName);

cloud_client.setDefaultCollection(collectionName);

2)      With Proxy code

System.setProperty("javax.net.ssl.keyStore", keyStore);

System.setProperty("javax.net.ssl.keyStorePassword", keyStorePsswd);

System.setProperty("javax.net.ssl.trustStore", trustStore);

System.setProperty("javax.net.ssl.trustStorePassword", trustStorePsswd);
System.setProperty("http.proxyHost", ProxyHost);
System.setProperty("http.proxyPort", ProxyPort);
HttpHost proxy = new HttpHost(ProxyHost, Integer.parseInt(ProxyPort));
RequestConfig defaultRequestConfig = RequestConfig.custom()
                                         .setProxy(new HttpHost(ProxyHost, Integer.parseInt(ProxyPort))).build();

HttpGet httpget = new HttpGet();
httpget.setConfig(defaultRequestConfig);

HttpClientBuilder builder = HttpClientBuilder.create();
builder.useSystemProperties();
CloseableHttpClient httpclient = builder.build();
httpclient.execute(proxy, httpget);
cloud_client = new CloudSolrClient(zkHost, httpclient);
@SuppressWarnings("rawtypes")
SolrRequest req = new QueryRequest();
req.setBasicAuthCredentials(UserName, Password);
cloud_client.request(req, collectionName);
cloud_client.setDefaultCollection(collectionName);


Please note that the Zookeepers are already whitelisted in the proxy under TCP protocol & SOLR servers are under https protocol.
Could someone please advise on this??

Thanks and Regards,
Preeti Bhat



NOTICE TO RECIPIENTS: This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender and it-support@shoregrp.com immediately, and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.