Timeout Issue with Invoke-WebRequest in PowerShell for Java 17/Tomcat 10

0
17
Asked By TechieNinja42 On

I'm using a health-check script in Jenkins that runs on Windows PowerShell 5.1. The script tries to access an HTTPS endpoint like this: `$response = Invoke-WebRequest -Uri "https://${IP_Name}:2443/ngat-service/admin/health" -UseBasicParsing -TimeoutSec 600`. It works perfectly fine with our Java 8 + Tomcat 8 application, but with our new Java 17 + Tomcat 10 setup, I keep hitting a timeout error: `Invoke-WebRequest : The operation has timed out.` I've confirmed that the endpoint is reachable using `Test-NetConnection`, and even `curl` can access it, although it takes about 7 minutes to get the full HTML back. My script is set to force TLS 1.2 and to ignore certificate validation. Has anyone faced a similar issue? Any tips on resolving this would be greatly appreciated!

3 Answers

Answered By DebugMaster99 On

Are you checking if Java is properly bound to the necessary ports? You mentioned that port 2443 is reachable according to your `Test-NetConnection`, which is great. Just be careful with the `httpRuntime executionTimeout` you found in the web.config. That setting can definitely lead to timeouts if they don't match your needs.

Answered By QuickFix101 On

A 7-minute response time definitely sounds like something's off with the app. It might be worth digging into the Java 17/Tomcat 10 configuration to see if there's a performance hitch causing the delay. If everything else is passing, this could be where the issue lies.

Answered By PowerUser123 On

Have you thought about running your script in PowerShell 7? I had a similar problem recently, and updating to PS7 and tweaking some syntax surprisingly resolved my issue. It might be a quick fix!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.