-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Invoke-WebRequest/RestMethod: Rename TimeoutSec to ConnectTimeoutSec and alias to TimeoutSec and add NetworkTimeoutSec timeout #19519
Comments
how many timeout with http client?It's best to add it all at once. connectTimeout https://learn.microsoft.com/en-us/dotnet/api/system.net.httplistenertimeoutmanager?view=net-7.0
I saw you adding a cancellation token to IWR. Do you have time to address this issue? |
That is the server side listener not the client side http handler. There
are more timeouts available on socket http handler class but PowerShell is
not using that class - it is still using httpclienthandler and changing
over would be an issue all of its own as it's not a trivial change and
risks breaking some corner case behaviour.
I think if you need that level of control then you probably want to write
your own code using httpclient as iwr already has a very large number of
parameters.
|
We have to proceed from realistic scenarios. There are actually two types (1) get/send small data with a request, (2) upload/download file. |
You could also be uploading/downloading data you have no intention of storing in a file so I'm not sure it's as clear cut as having two options and an easy, automatic choice between what to do with the parameter. Simplest implementation is a straight timeout on the receipt of all data but as has been discussed before this doesn't work well when we don't know ahead of time how long the download will take because of varying loads/network speeds etc. The main advantage of this sort of timeout is it could be implemented by using Another option is a "no packet received" timeout which would reset every time some data is received. This is more challenging to implement because there's no direct support for this kind of timeout in the core libraries used. Unfortunately, the WG didn't really give much guidance when writing that statement as to whether it was intending it to be a timeout for the overall download time or a "no packet received in x period" timeout or some hybrid of the two. Both might be useful depending on the use case but it may be surprising if the same parameter has a different behaviour depending on whether we are downloading to a file or not. @iSazonov could you be a bit more specific about what you expect since others may have a different view point and it's good to be explicit. |
In short, the only meaning of this parameter is the timeout for any atomic operation. |
Rename TimeoutSec to ConnectTimeoutSec |
@iSazonov - so what you're saying is the timeout should only ever mean "length of time between received data chunks/packets/whatever" has been exceeded, and should in no way apply to the entire length of the download, regardless of the use case involved. There might be some benefit in having an additional parameter that caps the overall download time, but that is probably overkill and wasn't requested by the WG. Do you have any thoughts on that? |
@stevenebutler The parameter you ask makes no sense because download time is unpredictable. Any component (client, server, network) can be either faster or slower. Moreover, the size of the file is in general also unpredictable. (For example, the size of a daily log file can be 1 Mb or 10Gb.) You can say that "my file always uploads no more than a minute and I agree to wait even an hour". But a timeout of one hour makes no sense because the server will close the session if there is a delay of any operation for about a minute, and a high-loaded server will do it even earlier. |
I think the |
From the WG notes they suggested defaulting to not have any timeout which is leaving the default situation where it will hang until someone CTRL-C the download if the OS doesn't report the loss of connection. Are you suggesting the default should be something other than no timeout? If the WG have decided on a course of action, is that what should be implemented, or is it still up for further debate? |
I don't know if it's up for further debate, but in my opinion we should follow PS5 behaviour described in #12249. Would you be open to reconsider @SteveL-MSFT |
PR above adds the feature as per the discussion here, and with the timeout defaulting to disabled. If WG wants to change the default that will be trivial to do. |
🎉This issue was addressed in #19558, which has now been successfully released as Handy links: |
Rename the parameter with an alias based on this wg-powershell-cmdlets review comment
@PowerShell/wg-powershell-cmdlets reviewed this. Based on the documentation currently,
-TimeoutSec
is for the initial connection and the definition of this parameter should not change. We suggest renaming this parameter to -ConnectTimeoutSec and alias to-TimeoutSec
. For this new capability, we propose adding a new-NetworkTimeoutSec
(default to 0 meaning infinite) to handle the case of intermittent network issues.Originally posted by @SteveL-MSFT in #18005 (comment)
The text was updated successfully, but these errors were encountered: