diff --git a/client/src/main/java/io/cloudsoft/winrm4j/client/ShellCommand.java b/client/src/main/java/io/cloudsoft/winrm4j/client/ShellCommand.java index 23b54aef..652116b1 100644 --- a/client/src/main/java/io/cloudsoft/winrm4j/client/ShellCommand.java +++ b/client/src/main/java/io/cloudsoft/winrm4j/client/ShellCommand.java @@ -122,11 +122,15 @@ private int receiveCommand(String commandId, Writer out, Writer err) { stream.setCommandId(commandId); stream.setValue("stdout stderr"); receive.setDesiredStream(stream); - + final OptionSetType optSetCmd = new OptionSetType(); + OptionType optKeepalive = new OptionType(); + optKeepalive.setName("WSMAN_CMDSHELL_OPTION_KEEPALIVE"); + optKeepalive.setValue("TRUE"); + optSetCmd.getOption().add(optKeepalive); try { numberOfReceiveCalls++; - ReceiveResponse receiveResponse = winrm.receive(receive, WinRmClient.RESOURCE_URI, WinRmClient.MAX_ENVELOPER_SIZE, operationTimeout, locale, shellSelector); + ReceiveResponse receiveResponse = winrm.receive(receive, WinRmClient.RESOURCE_URI, WinRmClient.MAX_ENVELOPER_SIZE, operationTimeout, locale, shellSelector, optSetCmd); getStreams(receiveResponse, out, err); CommandStateType state = receiveResponse.getCommandState(); diff --git a/client/src/test/java/io/cloudsoft/winrm4j/client/RetryingProxyHandlerTest.java b/client/src/test/java/io/cloudsoft/winrm4j/client/RetryingProxyHandlerTest.java index 68986d39..cd3c4d01 100644 --- a/client/src/test/java/io/cloudsoft/winrm4j/client/RetryingProxyHandlerTest.java +++ b/client/src/test/java/io/cloudsoft/winrm4j/client/RetryingProxyHandlerTest.java @@ -171,8 +171,8 @@ public void delete(String resourceURI, int maxEnvelopeSize, String operationTime } @Override - public ReceiveResponse receive(Receive receive, String resourceURI, int maxEnvelopeSize, String operationTimeout, Locale locale, SelectorSetType selectorSet) { - RecordedCall call = new RecordedCall("receive", Arrays.asList(receive, resourceURI, maxEnvelopeSize, operationTimeout, locale, selectorSet)); + public ReceiveResponse receive(Receive receive, String resourceURI, int maxEnvelopeSize, String operationTimeout, Locale locale, SelectorSetType selectorSet, OptionSetType optionSet) { + RecordedCall call = new RecordedCall("receive", Arrays.asList(receive, resourceURI, maxEnvelopeSize, operationTimeout, locale, selectorSet, optionSet)); calls.add(call); return (ReceiveResponse) handler.apply(call); } diff --git a/client/src/test/resources/recordings/win12.xml b/client/src/test/resources/recordings/win12.xml index 4df950ab..c2241cd4 100644 --- a/client/src/test/resources/recordings/win12.xml +++ b/client/src/test/resources/recordings/win12.xml @@ -209,6 +209,12 @@ xmlns:ns3="http://schemas.xmlsoap.org/ws/2004/09/transfer"> AF161CE1-3D3F-46B7-A101-800DD70639A9 + + TRUE + DDAD7559-3B88-44FA-890B-7FD87F86CB6C + + TRUE +