Discussion:
[JSch-users] Concurrency with JSch
Lahiru Gunathilake
2014-10-07 18:18:24 UTC
Permalink
Hi All,

I have extended the JCraft library to authenticate my servers with a token
and everything works fine when I use in the serial mode. But when I moved
to a thread pool and try to share the JCraftSession and try to create
multiple channels in large number of threads (I have already increased my
maxSessionCount in sshd_config) I get the following error and I am not sure
what is really going on.

Every 20-30 request I get the below error.


"com.jcraft.jsch.JSchException: channel is not opened."


Anybody using the sessions and creating channels concurrently ? I am not
synchronizing the session in each thread ? Should I synchronize the session
object if I am using in multi-threaded mode ?

Regards
Lahiru
--
Research Assistant
Science Gateways Group
Indiana University
Lahiru Gunathilake
2014-10-07 18:34:54 UTC
Permalink
Hi Users,

And when I remove the threadpool an still submit a very large load I can
see I am getting the following error intermittently,

com.jcraft.jsch.JSchException: Packet corrupt


at com.jcraft.jsch.Session.start_discard(Session.java:1049)

at com.jcraft.jsch.Session.read(Session.java:956)

at com.jcraft.jsch.UserAuthNone.start(UserAuthNone.java:56)

at com.jcraft.jsch.Session.connect(Session.java:389)

at com.jcraft.jsch.Session.connect(Session.java:183)


Regards

Lahiru
Post by Lahiru Gunathilake
Hi All,
I have extended the JCraft library to authenticate my servers with a token
and everything works fine when I use in the serial mode. But when I moved
to a thread pool and try to share the JCraftSession and try to create
multiple channels in large number of threads (I have already increased my
maxSessionCount in sshd_config) I get the following error and I am not sure
what is really going on.
Every 20-30 request I get the below error.
"com.jcraft.jsch.JSchException: channel is not opened."
Anybody using the sessions and creating channels concurrently ? I am not
synchronizing the session in each thread ? Should I synchronize the session
object if I am using in multi-threaded mode ?
Regards
Lahiru
--
Research Assistant
Science Gateways Group
Indiana University
--
Research Assistant
Science Gateways Group
Indiana University
guillaume cornet
2014-11-17 16:22:19 UTC
Permalink
Hi Lahiru !


I'm creating many SftpChannel in multiple Session and I'm facing the same
issue (e.g. 'Packet corrupt' or 'connection is closed by foreign host').

In order to solve this issue, I've introduce an retry mechanism in my code,
so that a new Session is created an openend when such error are detected.

I know it is not the best solution, but it was easier to do this rather
than modifying JCraft source code to make it thread safe.


Does anybody encounter such concurrency issue ?



G.
Post by Lahiru Gunathilake
Hi Users,
And when I remove the threadpool an still submit a very large load I can
see I am getting the following error intermittently,
com.jcraft.jsch.JSchException: Packet corrupt
at com.jcraft.jsch.Session.start_discard(Session.java:1049)
at com.jcraft.jsch.Session.read(Session.java:956)
at com.jcraft.jsch.UserAuthNone.start(UserAuthNone.java:56)
at com.jcraft.jsch.Session.connect(Session.java:389)
at com.jcraft.jsch.Session.connect(Session.java:183)
Regards
Lahiru
Post by Lahiru Gunathilake
Hi All,
I have extended the JCraft library to authenticate my servers with a
token and everything works fine when I use in the serial mode. But when I
moved to a thread pool and try to share the JCraftSession and try to create
multiple channels in large number of threads (I have already increased my
maxSessionCount in sshd_config) I get the following error and I am not sure
what is really going on.
Every 20-30 request I get the below error.
"com.jcraft.jsch.JSchException: channel is not opened."
Anybody using the sessions and creating channels concurrently ? I am not
synchronizing the session in each thread ? Should I synchronize the session
object if I am using in multi-threaded mode ?
Regards
Lahiru
--
Research Assistant
Science Gateways Group
Indiana University
--
Research Assistant
Science Gateways Group
Indiana University
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
Lahiru Gunathilake
2014-11-17 17:45:26 UTC
Permalink
Hi guillaume,

I was able tohandle it in my code level by synchronizing the code.
Everything works fine, I share sessions but synchronized the methods.

Lahiru

On Mon, Nov 17, 2014 at 11:22 AM, guillaume cornet <
Post by guillaume cornet
Hi Lahiru !
I'm creating many SftpChannel in multiple Session and I'm facing the same
issue (e.g. 'Packet corrupt' or 'connection is closed by foreign host').
In order to solve this issue, I've introduce an retry mechanism in my
code, so that a new Session is created an openend when such error are
detected.
I know it is not the best solution, but it was easier to do this rather
than modifying JCraft source code to make it thread safe.
Does anybody encounter such concurrency issue ?
G.
Post by Lahiru Gunathilake
Hi Users,
And when I remove the threadpool an still submit a very large load I can
see I am getting the following error intermittently,
com.jcraft.jsch.JSchException: Packet corrupt
at com.jcraft.jsch.Session.start_discard(Session.java:1049)
at com.jcraft.jsch.Session.read(Session.java:956)
at com.jcraft.jsch.UserAuthNone.start(UserAuthNone.java:56)
at com.jcraft.jsch.Session.connect(Session.java:389)
at com.jcraft.jsch.Session.connect(Session.java:183)
Regards
Lahiru
Post by Lahiru Gunathilake
Hi All,
I have extended the JCraft library to authenticate my servers with a
token and everything works fine when I use in the serial mode. But when I
moved to a thread pool and try to share the JCraftSession and try to create
multiple channels in large number of threads (I have already increased my
maxSessionCount in sshd_config) I get the following error and I am not sure
what is really going on.
Every 20-30 request I get the below error.
"com.jcraft.jsch.JSchException: channel is not opened."
Anybody using the sessions and creating channels concurrently ? I am not
synchronizing the session in each thread ? Should I synchronize the session
object if I am using in multi-threaded mode ?
Regards
Lahiru
--
Research Assistant
Science Gateways Group
Indiana University
--
Research Assistant
Science Gateways Group
Indiana University
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
--
Research Assistant
Science Gateways Group
Indiana University
Bogdan SOLGA
2014-11-18 08:14:45 UTC
Permalink
Hello, Guillaume!

I had the same issues with JSCH, and still haven't figured out a proper way
to handle the thread safety, besides executing in multiple threads and
using a retry mechanism.

I would also be interested to find a better way, though.

Kind regards,
Bogdan


On Mon, Nov 17, 2014 at 6:22 PM, guillaume cornet <
Post by guillaume cornet
Hi Lahiru !
I'm creating many SftpChannel in multiple Session and I'm facing the same
issue (e.g. 'Packet corrupt' or 'connection is closed by foreign host').
In order to solve this issue, I've introduce an retry mechanism in my
code, so that a new Session is created an openend when such error are
detected.
I know it is not the best solution, but it was easier to do this rather
than modifying JCraft source code to make it thread safe.
Does anybody encounter such concurrency issue ?
G.
Post by Lahiru Gunathilake
Hi Users,
And when I remove the threadpool an still submit a very large load I can
see I am getting the following error intermittently,
com.jcraft.jsch.JSchException: Packet corrupt
at com.jcraft.jsch.Session.start_discard(Session.java:1049)
at com.jcraft.jsch.Session.read(Session.java:956)
at com.jcraft.jsch.UserAuthNone.start(UserAuthNone.java:56)
at com.jcraft.jsch.Session.connect(Session.java:389)
at com.jcraft.jsch.Session.connect(Session.java:183)
Regards
Lahiru
Post by Lahiru Gunathilake
Hi All,
I have extended the JCraft library to authenticate my servers with a
token and everything works fine when I use in the serial mode. But when I
moved to a thread pool and try to share the JCraftSession and try to create
multiple channels in large number of threads (I have already increased my
maxSessionCount in sshd_config) I get the following error and I am not sure
what is really going on.
Every 20-30 request I get the below error.
"com.jcraft.jsch.JSchException: channel is not opened."
Anybody using the sessions and creating channels concurrently ? I am not
synchronizing the session in each thread ? Should I synchronize the session
object if I am using in multi-threaded mode ?
Regards
Lahiru
--
Research Assistant
Science Gateways Group
Indiana University
--
Research Assistant
Science Gateways Group
Indiana University
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
Loading...