Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring SFTP max packet size #9380

Closed
gbaso opened this issue Aug 12, 2024 · 1 comment
Closed

Allow configuring SFTP max packet size #9380

gbaso opened this issue Aug 12, 2024 · 1 comment

Comments

@gbaso
Copy link

gbaso commented Aug 12, 2024

Expected Behavior

Provide a property on the DefaultSftpSessionFactory that allows to configure the max packet size:

DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory()
factory.setMaxPacketSize(maxPacketSize);

Current Behavior

Max packet size is not configurable via DefaultSftpSessionFactory. It defaults to 32KB according to org.apache.sshd.core.CoreModuleProperties#DEFAULT_MAX_PACKET_SIZE. To change it, you must create your own SshClient and update the property:

SshClient sshClient = SshClient.setUpDefaultClient();
PropertyResolverUtils.updateProperty(sshClient, "packet-size", <value>);

however this prevents the DefaultSftpSessionFactory to initialize the client via doInitInnerClient(), therefore the ServerKeyVerifier, PasswordIdentityProvider, KeyIdentityProvider and UserInteraction must also be configured on the client instead of relying on the cleaner API from the DefaultSftpSessionFactory.

Context

I need to change the max packet size in order to reduce the amount of remote calls for more data in my Sftp.inboundStreamingAdapter integration flow, due to complaints from our SFTP server maintainer. Alternatively, we could reduce the rate at which we read from the remote InputStream, but that would slow down and add complexity to the integration flow

@gbaso gbaso added status: waiting-for-triage The issue need to be evaluated and its future decided type: enhancement labels Aug 12, 2024
@artembilan
Copy link
Member

Well, that's exactly why we have introduced that ctor:

	/**
	 * Instantiate based on the provided {@link SshClient}, e.g. some extension for HTTP/SOCKS.
	 * @param sshClient the {@link SshClient} instance.
	 * @param isSharedSession true if the session is to be shared.
	 */
	public DefaultSftpSessionFactory(SshClient sshClient, boolean isSharedSession) {

So, you can provide any custom SshClient.

However I see you pain for the ServerKeyVerifier, PasswordIdentityProvider, KeyIdentityProvider and UserInteraction.
I think we will go ahead and introduce something like:

setSshClientConfigurer(Consumer<SshClient> sshClientConfigurer)

So, you can continue to use that default internal behavior, but will be able to customize it with required properties or so.
New feature for the current in-progress 6.4 version.
For those previous versions a workaround via mentioned ctor should be enough.

Thanks

@artembilan artembilan added this to the 6.4.0-M2 milestone Aug 12, 2024
@artembilan artembilan added in: sftp and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants