You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Goldstein Lyor (JIRA)" <ji...@apache.org> on 2019/07/30 18:30:00 UTC
[jira] [Commented] (SSHD-935) Synchronizing the Apache Mina client
connection between threads
[ https://issues.apache.org/jira/browse/SSHD-935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16896386#comment-16896386 ]
Goldstein Lyor commented on SSHD-935:
-------------------------------------
{quote}
For (3), I am using the shell channel to list remote host's files
{quote}
Why ? SFTP can do that for you - please note that managing shell channels is much more complicated - especially for a task such as listing remote files - which (as I have said) is something SFTP provides anyway
> Synchronizing the Apache Mina client connection between threads
> ---------------------------------------------------------------
>
> Key: SSHD-935
> URL: https://issues.apache.org/jira/browse/SSHD-935
> Project: MINA SSHD
> Issue Type: Question
> Affects Versions: 2.2.0
> Reporter: Zabee Ulla
> Priority: Major
>
> I have multiple threads accessing a prototype bean SFTPMinaClientConnector.java. Every thread has some random method whose entire job is to connect to a remote machine using the SFTPMinaClientConnector.java, get the job done and disconnect.
> The problem I am facing is connection synchronization. While one thread is still doing some task the other closes it resulting in connection already closed exception.
> Looks like every thread is using the same connection.
> Is it possible to get a different connection for every thread? If so, how can I do that?
> If not, how can I synchronize the connection? Is there something in Mina APIs that can help in this situation?
> Below is the connect() method from my SFTPMinaClientConnector.java through which every thread goes in
> public void connect(){
> try {
> SshClient _client = SshClient.setUpDefaultClient();
> _client.start();
> ConnectFuture connectFuture = _client.connect(_username, _host, portNumber);
> connectFuture.awaitUninterruptibly();
> _session = connectFuture.getSession();
> _session.addPasswordIdentity(_password);
> shellChannel = _session.createShellChannel();
> _session.auth().verify(30000L);
> if (_session.isAuthenticated())
> { LOG.debug("Authentication succeeded. SFTP channel opened and connected."); }
> sftpClient = SftpClientFactory.instance().createSftpClient(_session);
> }
> catch (Exception oie) \{ .... }
> }
> Thank you in advance,
> Zabee
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org