Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebClient timeout is not set correctly #4433

Open
StefanOssendorf opened this issue Jan 9, 2025 · 0 comments
Open

WebClient timeout is not set correctly #4433

StefanOssendorf opened this issue Jan 9, 2025 · 0 comments
Labels

Comments

@StefanOssendorf
Copy link
Contributor

StefanOssendorf commented Jan 9, 2025

Dear @StefanOssendorf now DefaultWebClient uses req.Timeout = timeout.Milliseconds; that will trigger the exception that timeout must be greater than 0 or infinite,.
I don't think the current implementation works as expected, for me to work with sync call I needed to create a new WebClient and use TotalMiliseconds.

Originally posted by @ctescu in #4431 (comment)

We are using timeout.Milliseconds here

private class DefaultWebClient(TimeSpan timeout, TimeSpan readWriteTimeout) : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
var req = base.GetWebRequest(address)!;
if (req is HttpWebRequest httpWebRequest)
{
if (readWriteTimeout > TimeSpan.Zero)
{
httpWebRequest.ReadWriteTimeout = readWriteTimeout.Milliseconds;
}
}
if (timeout > TimeSpan.Zero)
{
req.Timeout = timeout.Milliseconds;
}
return req;
}
}

instead of timeout.TotalMilliseconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant