You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "GeezFORCE (via GitHub)" <gi...@apache.org> on 2023/05/25 10:16:57 UTC

[GitHub] [mina-sshd] GeezFORCE opened a new issue, #380: Client Session Pooling

GeezFORCE opened a new issue, #380:
URL: https://github.com/apache/mina-sshd/issues/380

   ### Description
   
   Not sure if this is the right platform to ask, please direct to any other platform if not.
   
   Is there any docs/ samples which illustrates how we can pool a predefined number of Client Sessions for use frequently.
   
   ### Motivation
   
   I have an application for SFTP client where I need to regularly connect to an SFTP Server and to see if a set of files are present. Currently, I create a dedicated client, a session and sftp client each time when I need to do this. But, this is not scalable as the server imposes a restriction on the number of concurrent connections that can be established.
   
   ### Alternatives considered
   
   I tried to implement my own pooling establishing a fixed number of client sessions. But I am finding it hard to keep the sessions alive even by setting up the heartbeat api available.
   
   ### Additional context
   
   If this is already possible, please direct me to any samples available or kindly share how this can be implemented
   
   Thanks in advance


-- 
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: dev-unsubscribe@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] GeezFORCE commented on issue #380: Apache MINA SSHD : Client Session Pooling

Posted by "GeezFORCE (via GitHub)" <gi...@apache.org>.
GeezFORCE commented on issue #380:
URL: https://github.com/apache/mina-sshd/issues/380#issuecomment-1564402253

   Thank You Tomas for the comprehensive answer.
   
   I can confirm that my custom pool implementation was not successful due to the bug you mentioned. I was using the `SftpFileSystem`.
   
   We don't have control over the way the SFTP server works, so our only option is to periodically check for new files. The motivation behind me trying to implement pooling was our current implementation had to use multiple concurrent sessions for the same user as a consequence of the design.
   
   After reading your answer, I think the better approach will be to have a single connection/ session. Hence I will try to implement that. 
   
   Thanks again for your answer, feel free to close the issue.


-- 
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: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] tomaswolf commented on issue #380: Apache MINA SSHD : Client Session Pooling

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #380:
URL: https://github.com/apache/mina-sshd/issues/380#issuecomment-1563197659

   Several thoughts on that:
   
   - You always have to deal with sessions getting closed, whether or not there is a pool. You cannot control when a server disconnects you. You can try to delay it with heartbeats, but ultimately a connection may go down all the same for any number of reasons, including network failures outside the control of either client or server. A simple approach is: if you get a closed or closing session from the pool, discard it and create a new one.
   - If your server has a hard limit on the number of concurrent sessions, keep in mind that any session you open and keep open will prevent someone else from connecting. (Say, the server has a limit of 50, and you create 5 sessions and keep them open: now only 45 other clients can even connect to that server.)
   - You could use a single `SshClient`. That would save some per-connection overhead.
   - Why do you want to keep your session open for long at all? If you open a session, do your SFTP directory listing, download anything new, and then close the session, why do you even need a pool? Why would that be a problem? (If you're worried about being the 51st session on the next check and thus not able to connect again: you have to handle this case anyway as it might occur already on your very first connection attempt.)
   - Why do you even have multiple concurrent sessions per server if you only want to check SFTP directories at one server? Are these directories for different users, requiring different log-ins? Then I don't see how a pool per server would help. And it wouldn't need a pool per user.
   - About sessions being closed: how exactly do you check the remote directory? If you're using an `SftpFileSystem`, see Apache MINA sshd bug [SSHD-1310](https://issues.apache.org/jira/browse/SSHD-1310).
   - I don't know your system and the constraints, but are you sure that polling via SFTP is the correct architecture? Did you consider making the server tell you when something new has arrived? It could, for instance, post an event or message on an event bus or message bus, and your client just subscribes to that event or message channel or topic, and goes download via SFTP whatever the event says was new. No need for long-lived SSH session with such an architecture. And I'm pretty sure that the top message bus/event bus systems do have SFTP source connectors that can do what you want.


-- 
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: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] tomaswolf closed issue #380: Apache MINA SSHD : Client Session Pooling

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf closed issue #380: Apache MINA SSHD : Client Session Pooling 
URL: https://github.com/apache/mina-sshd/issues/380


-- 
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: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org