justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.92k stars 598 forks source link

default proxy is error #908

Open BurningTeng opened 2 years ago

BurningTeng commented 2 years ago

For each loop, I have close it. But it can work after two times.

BurningTeng commented 2 years ago

For each loop, I have close it. But it can not work after two times.

honfika commented 2 years ago

Why do you do this? Only for testing? Do you stop it properly in the loop?

BurningTeng commented 2 years ago

Thanks for your reply.

Yes. I have stop it for each loop. Is there any limitation for times?

I do this because I need to capture picture by proxy for a login page. I need use proxy each time for diffrent user。

---Original--- From: @.> Date: Tue, Mar 22, 2022 22:05 PM To: @.>; Cc: @.**@.>; Subject: Re: [justcoding121/titanium-web-proxy] Start three times by loop, Itcan not work (Issue #908)

Why do you do this? Only for testing? Do you stop it properly in the loop?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

BurningTeng commented 2 years ago

https://github.com/BurningTeng/NeusoftSign/tree/v2.0

I have write code like below: for (var i =0 ;i < 10; i++) { var task = Task.Run(() => { su.StartProxyServer(); su.SetProxyPort(); su.Sign(listPerson[0].name, listPerson[0].email, listPerson[0].password); }) } ; For each loop. I close Proxy at Sign function. But when I tries three times, Proxy is error

honfika commented 2 years ago

but you execute them parallel.... you can't do that.

BurningTeng commented 2 years ago

The output is wrong when use diffrent port. You can test code via https://github.com/BurningTeng/NeusoftSign/tree/tmp. Main code as below:

SignProxy signProxy = new();

signProxy.StartProxyServer();
signProxy.SetProxyPort(8888);
SignUtils.Sign();
signProxy.StopProxyServer();

await Task.Delay(10000);

signProxy.StartProxyServer();
signProxy.SetProxyPort(9999);
SignUtils.Sign();
signProxy.StopProxyServer();

Sign function as below:

  public static void Sign()
  {
      /*            IWebDriver wd = new OpenQA.Selenium.Edge.EdgeDriver();
                  wd.Quit();*/
      Console.WriteLine("Doing a request");
      Console.WriteLine(HttpClient.DefaultProxy.GetProxy(new Uri("http://localhost")));

  }

For 9999 port, the output is wrong. I except the output should be http://localhost:9999/ other than 8888.

Listening on 'ExplicitProxyEndPoint' endpoint at Ip 0.0.0.0 and port: 8888
Set endpoint at Ip 0.0.0.0 and port: 8888 as System HTTP Proxy
Set endpoint at Ip 0.0.0.0 and port: 8888 as System HTTPS Proxy
Doing a request
http://localhost:8888/
Listening on 'ExplicitProxyEndPoint' endpoint at Ip 0.0.0.0 and port: 9999
Set endpoint at Ip 0.0.0.0 and port: 9999 as System HTTP Proxy
Set endpoint at Ip 0.0.0.0 and port: 9999 as System HTTPS Proxy
Doing a request
http://localhost:8888/