Invoke-RestMethod not honoring -timeoutset

Welcome Forums General PowerShell Q&A Invoke-RestMethod not honoring -timeoutset

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
  • #5314

    Points: 0
    Rank: Member

    by davidski at 2012-11-30 11:36:09

    Back with another question on Invoke-RestMethod, I'm afraid. Has anyone seen instances where Invoke-RestMethod does not honor the requested timeout setting specified via -TimeoutSec? I've running some potentially very long running calls where, once a call is made, the server will return nothing for a time ranging from minutes to hours. When I run these queries with Invoke-RestMethod and short-ish timeoutsec values, the calls look to just hang (infinite timeouts). Even worse, running these in the ISE and using the stop functionality hangs the entire PowerShell session. Closing that PS tab and opening new ones works fine, but it's darned annoying.

    Is this known problematic behavior? As handy as irm is, these sorts of issues are driving me back to the less slick, but seemingly more reliable [Net.HTTPWebRequest] and friends. I've got a fair amount of code now using irm and I'm not looking forward to refactoring that back to PoSH V2 cmdlets.


    by DonJ at 2012-11-30 12:23:42

    That's an issue in the underlying Framework, actually. I've run across it a bit myself, even in the v2 days.

    by davidski at 2012-11-30 15:31:12

    Argh. So even HTTPWebRequest won't solve this then? Have you found any way to get PoSH (or .NET in this case) to consistently fail for excessively long responses, allowing scripts to resume control and processing?

    by DonJ at 2012-11-30 15:47:27

    Never really tried. My Web servers all respond promptly . That's actually a problem that *should* be addressed server-side. Simply dropping the connection leaves the server with a hanging connection; it's the start of a DoS attack.

    And make sure the server isn't actually sending keep-alives. Most major Web languages (PHP, ASP, etc) will.

The topic ‘Invoke-RestMethod not honoring -timeoutset’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort