Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get NEST to work with Proxy, like Fiddler

Tags:

nest

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

like image 804
richardwhatever Avatar asked Mar 06 '14 07:03

richardwhatever


2 Answers

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.

like image 185
richardwhatever Avatar answered Sep 25 '22 01:09

richardwhatever


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.

like image 42
Martijn Laarman Avatar answered Sep 26 '22 01:09

Martijn Laarman