Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceStack JsonServiceClient, force traffic on the wire for localhost?

This ServiceStack client code works:

var client = new JsonServiceClient("http://localhost:32949/test");
var request = new MyRequest { ClassificationId = new ClassificationId (21300) };
var response = client.Post(request);

However, when observing the traffic in Fiddler, I see nothing. I would like to observe the traffic to get a better idea on how to build the required JSON request for other clients I have to write.

To make the above code work, I had to reference the assembly that has the service, and I am suspecting that ServiceStack is making some clever calls to avoid sending a HTTP request. Is this the case ?

Why am I not seeing any traffic in Fiddler, and how do I force it ?

HTTP traffic to localhost endpoints via the browser is shown correctly.

like image 380
driis Avatar asked Oct 10 '12 13:10

driis


3 Answers

Edit your hosts file, located at

C:\Windows\System32\drivers\etc\hosts

and add the following entry

127.0.0.1 mymachine.com

then point your client to mymachine.com instead of localhost

like image 122
wal Avatar answered Nov 14 '22 22:11

wal


I will answer my own question here - commenter @wal pointed out the problem to me:

This has nothing to do with ServiceStack, and requests actually go over the http protocol. The problem was looping back to localhost did not send the traffic through fiddler. It is actually explained on the Fiddler2 FAQ page.

like image 23
driis Avatar answered Nov 14 '22 22:11

driis


The other trick is to replace your "localhost" uri with your machine name, and that should work out of the box with Fiddler.

http://machinename:port/test

like image 35
realPT Avatar answered Nov 14 '22 23:11

realPT