如何让NEST与Proxy一起工作,比如Fiddler。

问题描述 投票:7回答:6

我试图将NEST的elasticsearch调用通过Fiddler传递给我,这样我就可以看到实际的json请求和响应。

我做了下面的工作来创建我的客户端,但是请求并没有通过代理推送(不管Fiddler是开启还是关闭,请求还是会被传递到elasticsearch)。

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

Fiddler没有用户名密码的要求,所以我只是传递随机文本。

我可以确认,在执行请求之前,我的elasticClient的proxy属性填入了上面指定的Uri,不过后面加了NEST的斜杠。

谢谢你

nest
6个回答
6
投票

好吧,所以,我放弃了NEST代理设置--它们似乎没有任何区别。

然而,在NEST客户端上将host设置为""。http:/ipv4.fiddler:9200。"而不是localhost通过Fiddler路由调用,达到了让我看到Elasticsearch的请求和响应的预期效果。


5
投票

如果你想在fiddler中看到.net应用的请求,你可以在webapp.config中指定代理。

正如小提琴家网站上记载的那样。

http:/docs.telerik.comfiddlerconfigure-fiddlertasksconfiguredotnetapp。

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

如果将主机名改为 ipv4.fiddler 不是一个选项。


3
投票

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

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

1
投票

这应该可以让它工作。

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

本回答.


1
投票

综合所有的建议,工作的解决方案是。

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

0
投票

这在7.6.1版本的NEST上是有效的,而且不需要切换。

DisableAutomaticProxyDetection

var settings = new ConnectionSettings(...);
settings.Proxy(new Uri(@"http://proxy.url"), "username", "password");
© www.soinside.com 2019 - 2024. All rights reserved.