I am having a problem where my code waits a long period of time on
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
What am I doing wrong? Sometimes I get bad proxies from my queue so I want to be able to timeout and skip.
Boolean match = false;
String clean = String.Empty;
String msbuff;
IWebProxy insideProxy;
try
{
//grab proxies based on queue
String proxyQueItem = Proxy_Que(_rankingConnectionString);
insideProxy = new WebProxy(proxyQueItem);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(ResultURL);
request.Proxy = insideProxy;
request.Timeout = 15*1000;
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
{
if (response.StatusCode == HttpStatusCode.OK)
{
Stream streamResponse = response.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
msbuff = streamRead.ReadToEnd();
//get rid of , -, (, )
msbuff = msbuff.Replace(" ", String.Empty).Replace(" ", String.Empty);
msbuff = msbuff.Replace("-", String.Empty);
msbuff = msbuff.Replace("(", String.Empty);
msbuff = msbuff.Replace(")", String.Empty);
//attempt to find phone number
match = msbuff.Contains(Listing.PhoneNumber);
streamRead.Close();
}
}
}
catch (Exception lk)
{ }