Skip to content

Creating a new client for each connection. #66

Description

@Tomnivore

Hey!

I'm using winrm-java to excute commands in Windows command prompt as follows (Mutiny):

Uni<WindowsRemoteCommandResult> executeUniCommand(TargetSystem targetSystem, PsCommands command) {
    return Uni.createFrom().item(() -> {
          try {
            // Execute the command using WinRMCommandExecutor
            log.atDebug().log("Executing command: " + command.getCommand());
            return WinRMCommandExecutor.execute(
                command.getCommand(),
                null,
                targetSystem.host(),
                null,
                targetSystem.user(),
                targetSystem.password().orElse("").toCharArray(),
                null,
                TIMEOUT,
                null,
                TICKET_CACHE,
                null);
          } catch (WindowsRemoteException e) {
            throw new RetryableWindowsConnectorException("Failed to execute remote command.", e);
          } catch (IOException | TimeoutException e) {
            throw new RetryableWindowsConnectorException("Command execution failed due to IO or timeout error.", e);
          }
         })
          .runSubscriptionOn(Infrastructure.getDefaultWorkerPool())
          .invoke(result -> validateResult(result, command.getDescription()));
  }

It seems that each subscription creates a new client and does calls to get soap schemas from different places. It feels like a waste of resources but also causes 429 errors if there's enough subscriptions going on. Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions