MihaZupan / HttpToSocks5Proxy

C# Http to Socks5 proxy implementation
227 stars 37 forks source link

OnAcceptCallback throw unhandled exception #6

Closed ductai230894 closed 5 years ago

ductai230894 commented 5 years ago

I tried throw exception inside the OnAcceptCallback method (HttpToSocks5Proxy class 101), the error always occurs, but cannot be processed inside the try catch block ..

Create an error : Edit the method OnAcceptCallback throw new exception ("test); Run test

IWebProxy webproxy = new HttpToSocks5Proxy ("127.0.0.1", 5789); Webclient webclient = new Webclient (); webclient.Proxy = webproxy;

try { webclient.DownloadString("https://google.com"); } catch(Exception e) { Console.Write("error"); //Don't throw bugs here }

MihaZupan commented 5 years ago

The OnAcceptCallback will executed on different threads than your webClient's DownloadString. Therefore you can't catch exceptions there.

What kind of exceptions are being thrown in the OnAcceptCallback?

ductai230894 commented 5 years ago

thank you, I understood