如何使NEST与代理商合作,如Fiddler

ric*_*ver 6 nest

我正试图从NEST通过Fiddler传递我的弹性搜索调用,所以我可以看到实际的json请求和响应.

我已经完成了以下操作来创建我的客户端,但是没有通过代理推送请求(如果Fiddler打开或关闭,请求仍然可以访问elasticsearch并不重要).

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

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

我可以确认,在执行请求之前,我的elasticClient具有使用上面指定的Uri填充的代理属性,尽管NEST添加了一个尾部斜杠.

谢谢

ric*_*ver 6

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

但是,将NEST客户端上的主机设置为" http://ipv4.fiddler:9200 "而不是localhost通过Fiddler路由调用,并实现了允许我查看来自Elasticsearch的请求和响应的预期结果.


Mar*_*man 5

如果您想查看 .net 应用程序在 fiddler 中发出的请求,您可以在 web/app.config 中指定代理

如 fiddler 网站上所述

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>
Run Code Online (Sandbox Code Playgroud)

如果ipv4.fiddler无法将主机名更改为 ,则很方便。