Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, May 25, 2016 1:25 PM
I have created a job that opens a webpage on our internal LAN. The webpage takes 4 to 5 minutes to complete it's process which is expected so I set a high timeout of 10 minutes.
The powershell job seems to run fine but I always get an error for getresponse get This is the error
***The corresponding line is '$response = $request.GetResponse() '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Exception calling "GetResponse" with "0" argument(s): "The operation has timed out" **
Code:*
$request =[System.Net.WebRequest]::Create("http://myinternalsite.com")
$request.timeout = 60000; # 10 Minutes
$response = $request.GetResponse()
$response.Close()
I tried searching for a solution but nothing seemed to help me.
How can I resolve this issue?
Thanks
All replies (5)
Wednesday, May 25, 2016 7:14 PM ✅Answered
actually I got it working, my issue was my timeout was not long enough I missed a zero in my time out, It would timeout after one minute instead of 10 minutes.
Evidently that minute was long enough for my page to execute but not long enough to get a response.
$request =[System.Net.WebRequest]::Create("http://myinternalsite.com")
$request.timeout = 600000; # 10 Minutes
$response = $request.GetResponse()
$response.Close()
Wednesday, May 25, 2016 1:30 PM
The server is timing out the request for some reason. As the webmaster to check the logs.
\(ツ)_/
Wednesday, May 25, 2016 5:24 PM
The IIS log shows a status of 200 for my request which means is completed successfully.
This script does open a page with Ajax on it.
Wednesday, May 25, 2016 6:27 PM
The IIS log shows a status of 200 for my request which means is completed successfully.
This script does open a page with Ajax on it.
You cannot access Ajax pages with this method. Ajax pages do not ever actually complete. The client will timeout.
You need a browser to execute the JavaScript that implements Ajax. WebRequest does not do this.
\(ツ)_/
Thursday, May 26, 2016 3:04 AM | 1 vote
Hi,
Glad you get it working and thanks for the sharing.
Best Regards,
Elaine
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected].