Alon Goldshuv
2016-06-02 11:16:32 UTC
Hello,
I'd like to perform multiple operations on an sftp server from multiple
threads simultaneously. All threads are servicing the same user connecting
to the same server sftp server.
Example:
- thread 1 performs a get() on file 1
- thread 2 performs a get() on file 2
- thread 3 performs a ls() on dir 3
- etc...
In my initial implementation I created a single session and a single
channel of type 'sftp', and shared it between all threads/requests. However
this doesn't seem to work - the InputStream used for get() can't be shared
across multiple requests and it gets closed when the second get() request
comes in.
What is the best practice for such a requirement? should each thread create
a new sftp channel and close it when done? do I also need a new session per
thread or can I still use a single user session and keep opening channels
from it on demand? is there a limit on how many sessions or channels can
(or should) be opened at the same time?
Appreciate your advice.
Alon.
I'd like to perform multiple operations on an sftp server from multiple
threads simultaneously. All threads are servicing the same user connecting
to the same server sftp server.
Example:
- thread 1 performs a get() on file 1
- thread 2 performs a get() on file 2
- thread 3 performs a ls() on dir 3
- etc...
In my initial implementation I created a single session and a single
channel of type 'sftp', and shared it between all threads/requests. However
this doesn't seem to work - the InputStream used for get() can't be shared
across multiple requests and it gets closed when the second get() request
comes in.
What is the best practice for such a requirement? should each thread create
a new sftp channel and close it when done? do I also need a new session per
thread or can I still use a single user session and keep opening channels
from it on demand? is there a limit on how many sessions or channels can
(or should) be opened at the same time?
Appreciate your advice.
Alon.