2014-03-06 61 views
5

我试图通过Fiddler从NEST传递我的elasticsearch调用,以便我可以看到实际的json请求和响应。如何让NEST与代理一起工作,如Fiddler

我已经做了以下创建我的客户端,但该请求没有通过代理推(如果提琴手是打开还是关闭,请求仍然到达elasticsearch也没关系)。

ConnectionSettings cs = new ConnectionSettings(uri); 
cs.SetProxy(new Uri("http://localhost:8888"),"username", "password"); 
elasticClient = new ElasticClient(cs); 

提琴手没有用户名/密码要求,所以我只是通过随机文本。

我可以证实,在该点只是执行的请求我elasticClient具有指定与乌里填入代理财产之上,但与NEST增加了尾部斜杠前。

感谢

回答

5

好了,所以,我放弃了在鸟巢代理设置 - 他们似乎没有任何区别。

但是,将NEST客户端上的主机设置为“http://ipv4.fiddler:9200”而不是本地主机将通过Fiddler路由该呼叫,并获得期望的结果,允许我从Elasticsearch中查看请求和响应。

+0

很大,它的工作完美 –

4

如果你想看到的是.NET应用程序,使在小提琴手的要求,你可以在web/app.config中

指定代理作为小提琴手的网站上记载

http://docs.telerik.com/fiddler/configure-fiddler/tasks/configuredotnetapp

<system.net> 
    <defaultProxy> 
     <proxy 
      autoDetect="false" 
      bypassonlocal="false" 
      proxyaddress="http://127.0.0.1:8888" 
      usesystemdefault="false" /> 
     </defaultProxy> 
</system.net> 

方便,如果更改主机名到ipv4.fiddler是不是一种选择。

+1

感谢马亭,很好的提示! SetProxy方法在NEST ElasticClient的ConnectionSettings对象上做什么? – richardwhatever

1

这应该使其工作:

var settings = new ConnectionSettings(...) 
    .DisableAutomaticProxyDetection(false); 

this answer

1

结合所有的建议,工作的解决方案是:

var node = new Uri("http://myelasticsearchdomain.com:9200"); 
var settings = new ConnectionSettings(node) 
    .DisableAutomaticProxyDetection(false) 
    .SetProxy(new Uri("http://localhost:8888"), "", ""); 
3

上面的代码并没有帮助我。 所以,这里是我的变种

var node = new Uri("http://localhost.fiddler:9200"); 
var settings = new ConnectionSettings(node) 
    .DisableAutomaticProxyDetection(false) 
相关问题