Here, try using
WebProxy proxy = WebProxy.GetDefaultProxy()
client.Proxy = proxy;
Or for the first time you can override the timeout function and set timeout for webclient, on timeout call your function again to download data this will solve your issue where it is not working for the first time.
public class WebClientWithTimeout:WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest wr = base.GetWebRequest(address);
wr.Timeout = 5000;
return wr;
}
}
Can check this link for more detail :
C# Download URL to string or file with timeout using WebClient[
^]