2

I need to connect to our solr server which is behind a proxy(?). Following I tried (nothing special):

SolrServer server = new HttpSolrServer("https://urltosolr/solr");
try {
    SolrPingResponse pingResponse = server.ping();
} catch (SolrServerException e) {
    ....
}

stacktrace:

 org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: https://urltosolr/solr
 ...
 Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

After that I tried the other constructor for HttpSolrServer but I don't know how to set username and password correctly into HttpClient. Can anyone help?

javanna
  • 59,145
  • 14
  • 144
  • 125
user1731299
  • 567
  • 3
  • 10
  • 24
  • 1
    Possibly related to: http://stackoverflow.com/questions/9068759/solr-running-on-https-solrj-connection-issue – Dan Oct 09 '12 at 14:48

1 Answers1

4

I don't see where you're trying to connect through a proxy in your code, you only provided the solr url while creating the HttpSolrServer. You can provide your own HttpClient instance while creating your HttpSolrServer instance. Your HttpClient instance can contain the information about the proxy. The needed code should be the following, which you can find in the http-components examples:

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost(proxyHost, proxyPort, "http");
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
httpclient.getCredentialsProvider().setCredentials(
                    AuthScope.ANY,
                    new UsernamePasswordCredentials(username, password));
SolrServer solrServer = new HttpSolrServer(solrUrl, httpclient);

Looking more at your question, I don't think you need to connect using a proxy. You error is about https. Have a look at this other question and answers to see what you need to do. The version of httpclient you need to look at is 4.x.

Community
  • 1
  • 1
javanna
  • 59,145
  • 14
  • 144
  • 125