client.Proxy woes

2,737 views
Skip to first unread message

Stefano Baraldi

unread,
Sep 27, 2012, 6:55:24 AM9/27/12
to rest...@googlegroups.com
Hello,
just getting used to this wonderful library.

As i have already experienced in .NET and HttpWebRequest, if i don't set a proxy or bypass it, the requests are very slow (more than 5 secs even on local dev machine).
The same happens in RestSharp, so the following out of the box code is slow:

var client = new RestClient("http://mydev.test/api");
RestRequest request = new RestRequest("customer/{id}", Method.GET);
RestResponse response = (RestResponse) client.Execute(request);

if i set the client.Proxy to null nothing changes (it was already null).
If i use recommended methods like

client.Proxy = System.Net.HttpWebRequest.GetSystemWebProxy();
or
client.Proxy = System.Net.HttpWebRequest.DefaultWebProxy;

the same happens, slow initial response.

The only way that works is through a deprecated method:

client.Proxy = System.Net.HttpWebRequest.DefaultWebProxy;

this will make the request fast as lightning, but it's deprecated, so will it fail some day?

Does anyone know why this behaviour is happening?

thank you
SB

Evan Wondrasek

unread,
Jan 9, 2013, 8:36:52 PM1/9/13
to rest...@googlegroups.com
Hi Stefano,

I'm experiencing a similar issue, but I wanted to verify something in your post: The bolded text you say fixed the issue, but it looks like you've written "client.Proxy = System.Net.HttpWebRequest.DefaultWebProxy;" which you said does not fix the problem in a previous paragraph. Is this a copy and paste error, and if so, would you mind clarifying the fix?

Thanks!

Evan

Maxence Delannoy

unread,
Dec 7, 2013, 1:21:41 PM12/7/13
to rest...@googlegroups.com
Try: 

HttpWebRequest.DefaultWebProxy = null;

It works for me.
Message has been deleted

mame...@trainsolutions.com.ar

unread,
Jun 30, 2016, 3:25:24 PM6/30/16
to RestSharp

We just saved my life with this line. Look we tried everything and it did not work . Many thanks!
Reply all
Reply to author
Forward
0 new messages