coderZoe opened a new issue, #518:
URL: https://github.com/apache/mina-sshd/issues/518
### Version
sshd-core 2.12.0
### Bug description
Hello,
I am using sshd-core to interact with some hardware devices. My code is
structured as follows:
```java
public abstract class BaseSshSessionSender extends AbstractSessionSender {
protected SshClient client;
protected ClientSession session;
protected ClientChannel channel;
protected ScheduledExecutorService scheduledExecutorService;
public BaseSshSessionSender(Device device, SenderMetaData metaData,
ScheduledExecutorService scheduledExecutorService) {
super(device, metaData);
this.scheduledExecutorService = scheduledExecutorService;
}
protected void doConnect() throws Exception {
this.client = SshClient.setUpDefaultClient();
this.client.start();
this.client.setGlobalRequestHandlers(Arrays.asList(KeepAliveHandler.INSTANCE,
NoMoreSessionsHandler.INSTANCE));
ConnectFuture connectFuture = client.connect(metaData.getUserName(),
metaData.getIp(), metaData.getPort())
.verify(metaData.getConnectTimeout());
if (connectFuture.isConnected()) {
this.session = connectFuture.getSession();
} else {
this.status = SenderStatus.DISCONNECT;
throw new
ConnectException(connectFuture.getException().getMessage());
}
this.session.addPasswordIdentity(metaData.getPassword());
AuthFuture authFuture =
this.session.auth().verify(metaData.getAuthTimeout());
if (!authFuture.isSuccess()) {
throw new AuthException("auth fail:" +
authFuture.getException().getMessage());
}
this.channel = createChannel();
this.status = SenderStatus.CONNECTING;
}
public ClientChannel createChannel() throws Exception {
ClientChannel channel =
this.session.createChannel(ClientChannel.CHANNEL_SHELL);
channel.setStreaming(ClientChannel.Streaming.Async);
channel.open().verify();
channel.getAsyncOut().read(new
ByteArrayBuffer(BUFFER_PIPE_SIZE)).addListener(new
ChannelResponseListener(this));
return channel;
}
}
```
For each device, I create a `BaseSshSessionSender` object to communicate,
maintaining a long connection with the device. However, I've noticed that
creating such a device connection spawns `cpu*2` threads. For instance, with
100 devices on an 8-core CPU, maintaining these connections requires 1600
threads, which is a substantial overhead. Given that my communication with
these devices is infrequent, I do not need so many threads.
I am looking for a way to specify the number of I/O threads during
connection setup, similar to how one might use bootstrap.group(new
NioEventLoopGroup(1)) in Netty. Does sshd-core support this configuration? If
so, how can I set it up?
Thank you for your assistance.
### Actual behavior
each device connection spawns `cpu*2` threads
### Expected behavior
specify the number of I/O threads during connection setup
### Relevant log output
_No response_
### Other information
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]