首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >连接到远程Solr实例的异常(407错误)

连接到远程Solr实例的异常(407错误)
EN

Stack Overflow用户
提问于 2013-07-29 12:01:08
回答 1查看 861关注 0票数 0

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

代码语言:javascript
复制
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);
        }

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

代码语言:javascript
复制
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运行良好,请让我知道如何修改,以连接到服务器,没有错误。

谢谢。

注意:主核心是我的Solr核心,我正在使用Solr 4.3

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-29 12:07:03

HTTP代码407意味着Proxy Authentication Required,您需要在通过HttpClient连接到服务器时设置身份验证信息。

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17923476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档