gateio / gateapi-csharp

36 stars 14 forks source link

How to add proxy support #2

Closed boyyao closed 3 years ago

boyyao commented 3 years ago

I want to use this API through proxy. How can I code it? thx~

revilwang commented 3 years ago

Not supported at the moment, but RestSharp is used as the http client. You can download the source code, and set the proxy in Exec function in ApiClient.cs file and add line

client.Proxy = new WebProxy("http://<your proxy host>:<your proxy port>");

before the client.Execute<T>(req) line.

We'll try to add this into configuration, so you don't need to modify the source code yourself.

boyyao commented 3 years ago

Thank you. I hope it can be used in the next version. And hope to support http and socks proxy

revilwang commented 3 years ago

New version 4.20.0 is published. You can now set a IWebProxy to Configuration, so that the client will use it.

Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.Proxy = new WebProxy("<your http proxy host>", <your http proxy port>);

Because RestSharp does not support socks proxy, so it is not possible for us right now to support it.

boyyao commented 3 years ago

thx... I noticed that the API reconnects SSL every time. Hope to keepactive

revilwang commented 3 years ago

I used the demo application, and captured traffic using wireshark, the result shows only one time SSL negotiation.

image