Skip to content

WebClient timeout is not set correctly #4433

Open
@StefanOssendorf

Description

@StefanOssendorf

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    • Status

      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions