jsch icon indicating copy to clipboard operation
jsch copied to clipboard

Getting garbage in InputStream when connecting to socket via proxy

Open ellabrom opened this issue 3 years ago • 4 comments

Sometimes, when connecting to socket via proxy (in Session.java), we get from InputStream some garbage , the process is stuck for about a minute and then below error is thrown: "connection is closed by foreign host" What can be a reason for such behavior? Attaching log with error and "garbage string" (look for word ella error_log.txt )

ellabrom avatar Jan 16 '22 13:01 ellabrom

  1. Can you provide example code displaying how your application is using the JSch library (it’s not obvious to me based upon your description what exactly you are doing)?
  2. What version of JSch are you utilizing?
  3. Are you using the binary Jar file published to Maven Central, or are you self-compiling the JSch library from source?

norrisjeremy avatar Jan 21 '22 11:01 norrisjeremy

Hi,

  1. Code example: private JSch jsch; private Session session; ... jsch = new JSch(); .... session = jsch.getSession(hostProperties.getUser(), hostProperties.getHostName(), hostProperties.getPort()); ..... ProxyHTTP proxy = new ProxyHTTP(proxyAddress,proxyPort); session.setProxy(proxy); session.setTimeout(SESSION_TIMEOUT); session.connect();
  2. 0.1.72
  3. We self-compile only below classes: Session, KnownHosts, ChannelSftp. All the rest - using binary jar.

Thanks, Ella

ellabrom avatar Jan 25 '22 14:01 ellabrom

Why do you self-compile the Session, KnownHosts & ChannelSftp classes? Are you applying custom changes to these classes?

norrisjeremy avatar Jan 25 '22 14:01 norrisjeremy

Hi @ellabrom,

In order to assist you further, can you help answer a few questions?

  1. The line numbers in the stacktrace you provided do not appear to correspond to the 0.1.72 release (lines 306 and 218) at places that would throw the JSchException you are reporting. Since you indicated that you are self-compiling the Session class, it would appear that you are modifying it in some way? If so, can you confirm this issue occurs when you don't self-compile the Session, KnownHosts & ChannelSftp classes and instead use the stock versions from the binary release, and if so provide a stacktrace using it?
  2. Can you provide more details on how your application works and is getting this garbage text from the InputStream? It is not clear to me how you are obtaining an InputStream and reading its contents to get this garbage text.
  3. Can you create a JSch Logger and capture JSch logging details (by creating a class that implements com.jcraft.jsch.Logger and calling JSch.setLogger(yourLoggerInstance); before you initialize your JSch session), then report the JSch Logger's output? If you look at #113, you can see some examples of how to create a JSch Logger that work with several different logging frameworks (java.util.logging, Log4j2 & SLF4j).

Thanks, Jeremy

norrisjeremy avatar Feb 03 '22 14:02 norrisjeremy