connection does not dispose properly
Bouki6 opened this issue · 7 comments
Hello.
I have been using this library in order to send my http request over Socks5. I'm using Httpwebrequest
. but after a while my server throw this exeption and drop all conections:
System.Net.Sockets.SocketException (0x80004005): An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at MihaZupan.HttpToSocks5Proxy..ctor(ProxyInfo[] proxyList, Int32 internalServerPort)
Are you creating a new instance of HttpToSocks5Proxy for every request?
Yes.
just like traditional WebProxy every time i created new one. is it wrong?
The HttpToSocks5Proxy instance is meant to be reused, or explicitly shut down by calling StopInternalServer. If you create a new one for each request you are essentially starting a new server that never stops, eventually running out of ports.
I will update the usage examples to make this clear.
thank you dear @MihaZupan for your great work.
so if i create a single HttpToSocks5Proxy instance(for example make it static) and use it all over my application, problem solves? I have more than 1000 proxies in my application.
If you are using the same proxy server for all requests, making it static is a good choice. If you are using different proxy servers then you should create a HttpToSocks5Proxy instance for each proxy server.
yes exactly. i will create static list of proxies. then reuse all over the code.
Great!
If you are making very few requests (i.e. less than 10/h per proxy), you can also create a new instance every time and call StopInternalServer.