Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to swftp server using ssh ftp throws session is down error when using JSch library #44

Open
sarathambadas opened this issue Nov 25, 2015 · 2 comments

Comments

@sarathambadas
Copy link

Hi
I am connecting to swftp using ssh ftp from a java program using JCch libraries. It works for some time and after that it throws session is down error. The SFTP server is running on softlayer

Caused by: com.jcraft.jsch.JSchException: session is down
at com.jcraft.jsch.Channel.sendChannelOpen(Channel.java:728)
at com.jcraft.jsch.Channel.connect(Channel.java:151)
at com.jcraft.jsch.Channel.connect(Channel.java:145)
at com.approuter.module.ftp.protocol.SftpConnectionImpl.(SftpConnectionImpl.java:108)
... 23 more

We try to reestablish a new session by cleaning of the resources (calling disconnect) but still face the same error even after retrying many number of times. Again suddenly it starts working after couple of hours.
Another thing is when this error occurs, it affects other clients as well who use the same credentials.

Can we know what is happening on the server side and how sessions are handled?
Is it possible to reuse a session once it gets corrupt/invalid. All channels returned by this session fail to work.

has anybody seen this issue?

Thanks
Sarath

@briancline
Copy link
Member

I can't say I've seen this issue first-hand or heard of it from others, however I also have not tried connecting to a SwFTP instance using the JSch library, either.

If you're using a number of simultaneous connections with the same credentials, you might be reaching the per-user connection limit that's configurable with the sessions_per_user in swftp.conf. The default is 10, although you can configure a higher limit.

Would you mind sharing some sample code that we can use to try and reproduce the issue?

@jbhattac
Copy link

jbhattac commented Jun 5, 2024

@briancline I am having the same issue as well.

Caused by: com.jcraft.jsch.JSchException: session is down
2024-06-05 09:28:55 
    at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-6.0.13.jar:6.0.13]
2024-06-05 09:28:55 
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-6.0.13.jar:6.0.13]
2024-06-05 09:28:55 
    at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
2024-06-05 09:28:55 
    at jdk.internal.reflect.GeneratedMethodAccessor34.invoke(Unknown Source) ~[na:na]

I observed from the Jsch logs that I am getting the following error even though I am disconnecting the connection.

: Caught an exception, leaving main loop due to SSH_MSG_DISCONNECT: 12 Maximum connections for host/user reached en-US

Code to disconnect the connection and that method is called from finally.

 private void disconnectSftp(ChannelSftp channelSftp){
        channelSftp.exit();
    }

My question is disconnecting for the channel not good enough, or we still do have to discoonect from the session explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants