I'm trying to create web request using tor.it's giving error "Unable to connect to the remote server" inner exception "No connection could be made because the target machine actively refused it 127.0.0.1:8118"
tor browser working fine.
Code:
static void Main(string[] args)
{
Process p = new Process();
p.StartInfo = new ProcessStartInfo(@"C:\Users\king\Downloads\Tor Browser\App\tor.exe", "ControlPort 9151 CircuitBuildTimeout 10");
p.Start();
Thread.Sleep(5000);
Regex regex = new Regex("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", RegexOptions.Multiline);
do
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://whatismyipaddress.com/");
request.Headers.Add("Cache-Control", "max-age=0");
request.Proxy = new WebProxy("127.0.0.1:8118");
request.KeepAlive = false;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
{
string contenu = reader.ReadToEnd();
Console.WriteLine(regex.Match(contenu).Groups[0].Value);
}
}
Console.Write("en attente : continuez ?");
string line = Console.ReadLine();
if (line != "y")
break;
}
while (true);
p.Kill();
Console.ReadLine();
}
}
thank's