i'm unsure if issue resides in spring integration or jcraft's jsch. have application on server takes in files , places them on server using sftp , session pools. ever receive stake traces start with:
java.lang.illegalstateexception: failed create sftp session caused by: java.lang.illegalstateexception: failed create sftp session caused by: java.lang.illegalstateexception: failed connect...
and ends 1 of following exceptions:
caused by: com.jcraft.jsch.jschexception: session down @ com.jcraft.jsch.channel.sendchannelopen(channel.java:762)
or
caused by: com.jcraft.jsch.jschexception: ssh_msg_disconnect: 11 session exceed concurrent session limit. please disconnect 1 or more of existing sessions , try again. @ com.jcraft.jsch.session.read(session.java:996) @ com.jcraft.jsch.userauthpublickey.start(userauthpublickey.java:198) @ com.jcraft.jsch.session.connect(session.java:463) @ com.jcraft.jsch.session.connect(session.java:183) @ org.springframework.integration.sftp.session.sftpsession.connect(sftpsession.java:263)
or
caused by: com.jcraft.jsch.jschexception: channel not opened. @ com.jcraft.jsch.channel.sendchannelopen(channel.java:765)
or
caused by: com.jcraft.jsch.jschexception: ssh_msg_disconnect: 2 flowsshpacketdecoder: received higher-level packet before first key exchange done @ com.jcraft.jsch.session.read(session.java:996) @ com.jcraft.jsch.session.connect(session.java:323) @ com.jcraft.jsch.session.connect(session.java:183) @ org.springframework.integration.sftp.session.sftpsession.connect(sftpsession.java:263) ... 45 more
these exceptions happen in groups. example, might session down 3 or 4 times in row within minute. mixed, maybe i'll channel not open session down. sometime, works without throwing exception.
my bean:
<bean id="cachingsessionfactory" class="org.springframework.integration.file.remote.session.cachingsessionfactory"> <constructor-arg ref="sftpsessionfactory" /> </bean> <bean id="sftpsessionfactory" class="org.springframework.integration.sftp.session.defaultsftpsessionfactory"> <constructor-arg name="issharedsession" value="true"/> <property name="host" value="${server}" /> <property name="port" value="22" /> <property name="user" value="${user}" /> <property name="privatekey" value="${keypath}" /> <property name="sessionconfig" ref="props"/> </bean>
the server connecting has maxsessions set 30 , connection timeout of 6 minutes. i've spent past couple of days trying debug errors, can't seem reproduce them.
multi-threading issue problem. application receive request push multiple files @ once (say 20+). issue session stale, 20+ threads trying create new session. server reaching out allowed 6 sftp connections @ once.
my solution keep session disconnecting adding
<property name="serveraliveinterval" value="60000" />
to bean. stops connection becoming stale, down side is connected (taking resources). think if want resolve threading issue, have remove spring , work jsch directly.
Comments
Post a Comment