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-unsubscr...@mina.apache.org

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


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

Reply via email to