Вопрос

I'm trying to pass my elasticsearch calls from NEST through Fiddler so I can see actual json requests and responses.

I've done the following to create my client, but the requests are not being pushed through the proxy (it doesn't matter if Fiddler is on or off, request still gets to elasticsearch).

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

Fiddler has no username/password requirements so I just pass random text.

I can confirm that at the point just before executing request my elasticClient has the proxy property filled in with Uri specified above, though with a trailing slash added by NEST.

Thanks

Это было полезно?

Решение

Okay, so, I gave up on the NEST proxy settings - they didn't seem to make any difference.

However, setting host on the NEST client to "http://ipv4.fiddler:9200" instead of localhost routes the call through Fiddler and achieved the desired result of allowing me to see both requests and responses from Elasticsearch.

Другие советы

If you want to see the requests a that .net application makes in fiddler you can specify the proxy in the web/app.config

As documented on fiddler's website

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>

Handy if changing the hostname to ipv4.fiddler is not an option.

Above code didn't help me. So, here is my variant

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

This should make it work:

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

See this answer.

Combining all the suggestions, the working solution is:

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

This works on NEST ver 7.6.1, and it's not necessary to toggle:

DisableAutomaticProxyDetection

var settings = new ConnectionSettings(...);
settings.Proxy(new Uri(@"http://proxy.url"), "username", "password");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top