Unexpected HTTP response 500 in WinRM | RunDeck
All admins would have faced some issue with Windows remote management starting from executing a long running command or fetching some data. When you start using different tools to execute the same over WinRM for better tracking purpose first time setup is always little hard. So here also we will discuss on how to correctly setup WinRM plugin over Rundeck so that you will not face much issue. Example, while executing jobs over winRM in a windows environment you would have faced 500 internal server error when the command is long running and takes plenty of time to finish. When we migrated all our WinRM scripts to RunDeck to make it more user friendly we faced the same “Unexpected HTTP response 500” error after each one minute of job run. On debugging we came to know its due to the default timeouts set on the overthere plugin used in rundeck winrm plugin. So to avoid this issue and allow users to run long running jobs over WinRM follow below steps to fix. How ever same steps mentioned in “WinRM settings in the remote host” can be followed in case you are not using RunDeck but facing the same issue while directly running commands via WinRM.
Errors Seen while executing the commands:
com.xebialabs.overthere.cifs.winrm.WinRmRuntimeIOException: Unexpected HTTP response on http://lap1.techpaste.com:5985/wsman: (500) at com.xebialabs.overthere.cifs.winrm.WinRmClient.doSendRequest(WinRmClient.java:419) at com.xebialabs.overthere.cifs.winrm.WinRmClient.sendRequest(WinRmClient.java:345) at com.xebialabs.overthere.cifs.winrm.WinRmClient.receiveOutput(WinRmClient.java:182) at com.xebialabs.overthere.cifs.winrm.CifsWinRmConnection$2.run(CifsWinRmConnection.java:162) [overthere-winrm:lap1.techpaste.com] failed: Unexpected HTTP response on http://lap1.techpaste.com:5985/wsman: (500) Failed: WinRMProtocolError: Unexpected HTTP response on http://lap1.techpaste.com:5985/wsman: (500)
Solution:
To fix this issue we need to do two types of changes.
- WinRM settings in the remote host
- Project config changes for WinRM in Rundeck
WinRM settings in the remote host:
1. Click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.
2. In the command prompt window, type the following commands, and press Enter after each command:
winrm set winrm/config @{MaxEnvelopeSizekb="4294967295"} winrm set winrm/config @{MaxTimeoutms = "4294967295"} winrm set winrm/config @{MaxBatchItems="4294967295"} winrm set winrm/config/Service @{MaxConcurrentOperations="4294967295"} winrm set winrm/config/Service @{MaxConcurrentOperationsPerUser="4294967295"} winrm set winrm/config/service @{EnumerationTimeoutms ="4294967295"} winrm set winrm/config/service @{MaxConnections ="50"} winrm set winrm/config/service @{MaxPacketRetrievalTimeSeconds ="4294967295"} winrm set winrm/config/service/auth @{CredSSP="True"} winrm set winrm/config/client @{TrustedHosts="*"} winrm set winrm/config/client @{NetworkDelayms="4294967295"} winrm set winrm/config/winrs @{IdleTimeout ="2147483647"} winrm set winrm/config/winrs @{MaxConcurrentUsers ="100"} winrm set winrm/config/winrs @{MaxShellRunTime ="2147483647"} winrm set winrm/config/winrs @{MaxProcessesPerShell ="5000"} winrm set winrm/config/winrs @{MaxShellsPerUser ="5000"} winrm set winrm/config/winrs @{AllowRemoteShellAccess="True"} winrm set winrm/config/winrs @{MaxMemoryPerShellMB="2048"}
3. Type exit, and then press Enter.
4. Restart WinRM service. (net stop winrm and net start winrm)
Project config changes for WinRM in Rundeck:
in rundeck WinRM plugin default WinRM timeout is set to PT60.000S which is 60 secs according to https://www.w3.org/TR/xmlschema-2/#isoformats , which is causing the WinRM jobs to timeout after 1minute. So we need to increase the timeout from rundeck side too to fix the issue. To increase timeout follow below steps:
- login to rundeck instance and cd to RUNDECK_HOME/projects/PROJECT_NAME/
- Open project.properties file in any text editor and add below two lines to increase the timeout values.
project.winrm-timeout=PT28800.000S project.winrm-connection-timeout=28800000
Note: Here we have put the timeouts to 8hrs but for your settings choose which ever suits.
Once all above has been set and active you shall be able to see the timeout settings getting reflected in jobs while running in debug mode like below:
Once above settings are set the job will no more timeout or throw 500 error till the timeout value reached.
In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.
Hi,
You might also want to have a look at the XebiaLabs documention. XebiaLabs is the maintainer of the overthere framework which is used by Rundeck to setup remote connection on windows.
https://docs.xebialabs.com/xl-deploy/how-to/set-up-winrm-in-xl-deploy-and-on-a-target-host.html
https://docs.xebialabs.com/xl-deploy/how-to/useful-winrm-commands.html
Also here you can find more information on the overthere framework.
Regards,
Joris
Thanks Joris for the reference docs. It will surely help visitors.
Thanks a lot, finally found a solution for WInRM 500 errors. I was aware about timeout setting on the server side, but didn’t know about Rundeck project WinRM timeout settings, and that was the root issue. Thank you again!
Glad it helped!
thank you so much, this works great
Appreciate it. Thanks
thank you so much, Work like Charm.