Fiddler4 in windows server 2012 provokes RestSharp

2019-08-25 13:35发布

问题:

So I'm testing Neo4J in pure REST (no Neo4JClient) and I have this code:

       var client = new RestClient("http://url");

        string requestText = "{  \"query\" : \"start x  = node(1) match path = (x--IsFriendOf) return path, IsFriendOf.name\",  \"params\" : {  }}";

        var request = new RestRequest();

        request.Method = Method.POST;
        request.RequestFormat = DataFormat.Json;
        request.Resource = "/foo/bar";
        request.AddHeader("Content-Length", requestText.Length.ToString());
        request.AddHeader("Host", "ip:port");
        request.AddHeader("Accept", "application/json");
        request.AddHeader("Content-Type", "application/json");

        request.AddHeader("Authorization", "Basic encoded64credentials");


        request.AddBody(requestText);



        IRestResponse response = client.Execute(request);

If I do the RAW request in Fiddler itself, I get the desired result,

But if I do it in a console application in .Net 4.5, I see this:

I created a rule in my firewall to allow incoming/outgoing requests for the console executable, and I deactivated IE protected mode, but still, no luck.

Do anyone have some idea about this issue?

回答1:

There are a number of things wrong here.

The first thing to understand is that you're not actually seeing the request at all-- the request you're showing in this screenshot is IE downloading Compatibility View List information, not any request you've made yourself.

You should probably start by reading http://blogs.msdn.com/b/fiddler/archive/2011/09/14/fiddler-and-windows-8-metro-style-applications-https-and-private-network-capabilities.aspx to understand how Windows 8 / Windows Server 2012 have changed and what you need to do to capture their traffic in a local loopback proxy.



回答2:

I can't believe what I'm writting, but apparently the error was produced by Fiddler itself, I will find out what are the inner mechanisms of Fiddler to interrupt my calls.

So if you are making an http request to a REST API that is not on port 80, and you are either using WireShark or Fiddler for example, the request never reaches the endpoint.

I don't know how to solve it, but I do know how to avoid it, and that is, close all traffic monitors on the server. In my case I had Wireshark and Fiddler4 opened to help me debug the http request content, but of course I could never realize what was happening because I was debugging with the tool that was provoking the error.

I'm using Fiddler4 in windows server 2012, with VS2012 and .Net Framework 4.5 if this is useful for anyone that has any hint on why that happens.