[英]Quartz job running - Could not connect to SFTP server - connection reset
Modified the descripton I have a quartz job running in that VM and i used to get this error修改了描述我在那个虚拟机中运行了一个石英作业,我曾经得到这个错误
org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "sftp://reports.staging.companyname.com/".
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:107)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:103)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:81)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:65)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:693)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:621)
at com.companyname.appname.connector.dropbox.sftp.PseSFTPConnection.doConnect(PseSFTPConnection.java:149)
at com.companyname.appname.connector.dropbox.sftp.PseSFTPConnection.connect(PseSFTPConnection.java:109)
at com.companyname.appname.connector.dropbox.sftp.DropboxDaoSFTPImpl.isAvailable(DropboxDaoSFTPImpl.java:183)
at com.companyname.appname.batch.jobs.DataFileProcessorJob.execute(DataFileProcessorJob.java:46)
at sun.reflect.GeneratedMethodAccessor137.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "reports.staging.companyname.com".
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:230)
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:96)
... 17 more
Caused by: com.jcraft.jsch.JSchException: Session.connect: java.net.SocketException: Connection reset
at com.jcraft.jsch.Session.connect(Session.java:565)
at com.jcraft.jsch.Session.connect(Session.java:183)
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:226)
... 18 more
sdfFileProcessing_Worker-9 2019-11-04 05:20:03,915 ERROR: com.companyname.appname.connector.dropbox.sftp.DropboxDaoSFTPImpl - Is available
when i use normal Sftp command line utility also getting "Connection reset by peer" "ssh_exchange_identification: read: Connection reset by peer Couldn't read packet: Connection reset by peer" from java code and normal Sftp command -> connection also fails.当我使用普通的 Sftp 命令行实用程序时,还从 java 代码和正常的 Sftp 命令中获取“连接重置”“ssh_exchange_identification:读取:对等连接重置无法读取数据包:对等连接重置”-> 连接也失败。
root@qa-batch:~# sftp userid_usercontinuation@somedomain.com
ssh_exchange_identification: read: Connection reset by peer
Couldn't read packet: Connection reset by peer
root@qa-batch:~# free -m
total used free shared buffers cached
Mem: 3953 3522 430 0 299 1570
-/+ buffers/cache: 1652 2300
Swap: 2047 6 2041
root@qa-batch:~#
I keep on getting this exception.我不断收到这个例外。
The issue is continuously reoccuring, and in the code using finally block properly disconnect the connection.该问题不断再次出现,并且在使用 finally 块的代码中正确断开连接。 I checked in some of stack overflow forums but they mentioned it might be a heap issue.
我查看了一些堆栈溢出论坛,但他们提到这可能是一个堆问题。 So i tried stoping the java quartz service, temporarily i am able to connect using sftp cli command (ie,. after 5 mins).
所以我尝试停止 java 石英服务,暂时我可以使用 sftp cli 命令连接(即,5 分钟后)。 But my requirement is the java application should be able to connet to sftp and read a remote file, then process and update to DB.
但我的要求是 java 应用程序应该能够连接到 sftp 并读取远程文件,然后处理并更新到 DB。
Usually "Connection reset by peer" means that there is an issue on the other end (SFTP remote server in this case), so the chances are that Quartz Job and Java in general are not "guilty".通常“对等方重置连接”意味着另一端(在这种情况下为 SFTP 远程服务器)存在问题,因此 Quartz Job 和 Java 通常没有“有罪”。 Probably sometimes you can also check the network for issues but that's not Java...
可能有时您也可以检查网络是否存在问题,但这不是 Java...
So in terms of resolution, first of all try connecting with some "non-java" client and see that sometimes you won't be able to connect as well.所以在分辨率方面,首先尝试连接一些“非java”客户端,看看有时你也无法连接。
After that, there is not much you can do:之后,您无能为力:
Retries, you can retry the connection attempt重试,可以重试连接尝试
Alternatively, if the business logic makes sense: run the job more frequently so that if one job execution failed to interact with the remote server, pretty quickly another trigger will start and probably you'll be more lucky this time.或者,如果业务逻辑有意义:更频繁地运行作业,这样如果一个作业执行未能与远程服务器交互,另一个触发器将很快启动,这一次你可能会更幸运。
I realize that all these are pretty bad workarounds, but again, without a stable connection to the remote part you can't really solve it in Java, sorry我意识到所有这些都是非常糟糕的解决方法,但同样,如果没有与远程部分的稳定连接,您无法在 Java 中真正解决它,抱歉
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.