✅ RestSharp not using given Proxy

Hey all! I know this is quite off topic from regular C# as this post is bound to a NuGet Package but maybe someone here knows how to help me Im trying to get my RestSharp requests run through proxies but somehow RestSharp is always using my real public IP address even tho im giving proper arguments and setting the proxy correctly my WebProxy object knows the IP i gave to it, but it seems that RestClient is just completely ignoring it and i couldnt find anything about it on the internet yet any help is greatly appreciated!
15 Replies
canton7
canton72y ago
How exactly do you determine that restsharp isn't using the proxy?
Somgör from Human Resources
i make a request to ifconfig and it responds with the IP address that it has recevied the reuquest from and it responds with my IP instead of the proxy
canton7
canton72y ago
How do you "make a request to ifconfig"?
canton7
canton72y ago
Ah there's actually a website with that name. I only know it as the name of the Linux util
Somgör from Human Resources
thats how i know what IP im using and i checked the proxy and all it parses the proxy properly and stuff therefore i conclude that RestSharp is not using my proxy
Instinct
Instinct2y ago
Had to restructure a bit the image you've sent, but for me it does the job
WebProxy proxy = new WebProxy("http://localhost:8000/")
{
BypassProxyOnLocal = false,
UseDefaultCredentials = false
};

RestClientOptions options = new()
{
Proxy = proxy,
MaxTimeout = 2000
};
RestClient client = new(options);

client.ExecuteGet(new RestRequest("https://google.com/"));
WebProxy proxy = new WebProxy("http://localhost:8000/")
{
BypassProxyOnLocal = false,
UseDefaultCredentials = false
};

RestClientOptions options = new()
{
Proxy = proxy,
MaxTimeout = 2000
};
RestClient client = new(options);

client.ExecuteGet(new RestRequest("https://google.com/"));
Maybe the problem's with the proxy? That if there's any problem to begin with
Instinct
Instinct2y ago
Actually no. The protocol is wrong, it should be in plural
Somgör from Human Resources
socks? it worked fine before its confusing to me that it just stopped uh now its not able to make the request in the first place the server isnt responding with any value at all its so weird ill try to use the default webclient
Instinct
Instinct2y ago
WebClient should be avoided, use HttpClient in its stead
Somgör from Human Resources
yes yes that i switched it up
Somgör from Human Resources
the proxies work i just checked
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Somgör from Human Resources
Solution: The Proxy API I was using for socks5 proxies started replying with http and https proxies that mostly didn't work Therefore couldn't connect to a socks protocol URL