Solr - instantiate HttpSolrServer with Httpclient

后端 未结 1 714
轻奢々
轻奢々 2021-01-22 10:35

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

SolrServer server = new HttpSolrServer(\"https://urltosolr/         


        
相关标签:
1条回答
  • 2021-01-22 11:03

    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.

    0 讨论(0)
提交回复
热议问题