i need ask lot of url`s powershell , check status code
$request = $null $request= [system.net.webrequest]::create($url) $request.timeout = 100 $request.allowautoredirect = $true try { $response = $request.getresponse() } catch [system.net.webexception] { $someexception = $_.exception.message } $http_status = [int]$res.statuscode if ([int]$response.statuscode.value__ -ne 200) #если не 200 - алерт { $state = 'error' } else { $state = 'ok' } $request.close
any way trying use on server - ok via manual test, if run lot of scripts (in m$ scom monitoring) - of them fail operation has timed out
if check problem url - ok
why can time out in case lot of scripts in 1 time?how debug it? http 200 server logs ..
the timeout property you're setting 100
in milliseconds.
that's pretty short. might want set few seconds.
it happens because server side took longer amount of time send data. may have sent 200 response entire request did not complete in time allotted. possible if you're sending lot of requests @ once.
Comments
Post a Comment