baba
baba
CC#
Created by baba on 1/12/2023 in #help
❔ exception for proxy help
hey guys, my c# knowledge isnt the best but i have a question plz im using this code:
private static async Task Check()
{
foreach (var cookieList in CookieList)
{
var user = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxyuser");
var pass = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxypass");
var proxyIp = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxyip");
var proxyPort = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxyport");
var container = new CookieContainer();
var handler = new HttpClientHandler();
handler.CookieContainer = container;
var client = new HttpClient(handler);
WebProxy proxy = new WebProxy(proxyIp,Convert.ToInt32(proxyPort));
if(user != null)
{
proxy.Credentials = new NetworkCredential(user, pass);
}
client.BaseAddress = BaseAddress; try
{
handler.Proxy = proxy;
}
catch
{
LogSystem.SendMessage("Proxy Error!", Log.Type.Message);
}
private static async Task Check()
{
foreach (var cookieList in CookieList)
{
var user = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxyuser");
var pass = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxypass");
var proxyIp = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxyip");
var proxyPort = JsonReader.readJSON("dataproxy.json", "proxyDetails", "proxyport");
var container = new CookieContainer();
var handler = new HttpClientHandler();
handler.CookieContainer = container;
var client = new HttpClient(handler);
WebProxy proxy = new WebProxy(proxyIp,Convert.ToInt32(proxyPort));
if(user != null)
{
proxy.Credentials = new NetworkCredential(user, pass);
}
client.BaseAddress = BaseAddress; try
{
handler.Proxy = proxy;
}
catch
{
LogSystem.SendMessage("Proxy Error!", Log.Type.Message);
}
whenever the proxy is failing the entire program is closing. can i know how to add the proper exception to either retry or use a new proxy or just skip ?
15 replies