【问题标题】:Exception connecting to Remote Solr Instance (407 error)连接到远程 Solr 实例的异常(407 错误)
【发布时间】:2013-07-29 20:07:03
【问题描述】:

我已经编写了下面提到的代码。

HttpSolrServer solrServer = new HttpSolrServer("http://10.40.4.171/solr/prime-core");
List<UserSolr> userList=null;
        SolrQuery q = new SolrQuery();
        q.setQuery("*:*");
        q.setStart(0);
        q.setRows(10);
        //SolrDocumentList results = null;
        try {
            QueryResponse response = solrServer.query(q);
            userList=response.getBeans(UserSolr.class);
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println(e);
        }

但对于上述情况,我收到以下错误:-

org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at http://10.40.4.171/solr/prime-core returned non ok status:407, message:Proxy Authorization Required

我无法解决这个问题。相同的代码在 url http://localhost:8080/solr/prime-core 上工作正常请告诉我如何修改以正确连接到服务器。

谢谢。

注意: prime-core 是我的 Solr 核心 我正在使用 Solr 4.3

【问题讨论】:

    标签: java apache search solrj solrcloud


    【解决方案1】:

    HTTP代码407暗示Proxy Authentication Required,通过HttpClient连接服务器时需要设置认证信息:

    httpclient.getCredentialsProvider().setCredentials(
                        AuthScope.ANY,
                        new UsernamePasswordCredentials(username, password));
    solrServer = new HttpSolrServer(solrUrl, httpclient);//with credentials
    

    您可能想查看类似的讨论:

    Solr - instantiate HttpSolrServer with Httpclient

    Solr 4 with basic authentication

    【讨论】:

    • 用户名和密码暗示代理的用户名和密码??对吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2016-08-25
    • 1970-01-01
    • 2011-10-22
    相关资源
    最近更新 更多