JSch com.jcraft.jsch.Session sftp连接超时时间timeout默认设置0 导致一直处于等待连接状态
线上排查发现一个定时任务task(原来每隔1小时跑一次的),5.7号只跑了一次,根据日志排查发现,打印了开始的日志,到连接sftp时,下面没有日志了
查看jvm堆栈信息:
jstack -l 63522 >63522-jstack.log
scheduler_Worker-25(日志里看到也是这个线程)
"scheduler_Worker-25" #38 prio=5 os_prio=0 tid=0x00007f0248e4a000 nid=0xf888 runnable [0x00007f0200fcb000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.net.SocketInputStream.read(SocketInputStream.java:224)
at com.jcraft.jsch.IO.getByte(IO.java:73)
at com.jcraft.jsch.Session.connect(Session.java:263)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.cmcc.open.ss.util.CommonSftpUtil.getSftpConnect(CommonSftpUtil.java:85)
at com.cmcc.open.task.service.PhoneAscriptionQueryTask.downloadAndBak(PhoneAscriptionQueryTask.java:190)
at com.cmcc.open.task.service.PhoneAscriptionQueryTask.getHoursPhoneNum(PhoneAscriptionQueryTask.java:159)
at com.cmcc.open.task.service.PhoneAscriptionQueryTask$$FastClassBySpringCGLIB$$fc62f4f8.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:737)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:84)
at com.cmcc.open.task.aop.TaskAspect.taskAspectMethod(TaskAspect.java:67)
at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:672)
at com.cmcc.open.task.service.PhoneAscriptionQueryTask$$EnhancerBySpringCGLIB$$24b5bb1a.getHoursPhoneNum(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cmcc.open.task.utils.MyDetailQuartzJobBean.executeInternal(MyDetailQuartzJobBean.java:50)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
- locked <0x00000006d21b37b8> (a java.lang.Object)
Locked ownable synchronizers:
- None
最后定位,是没有设置connectTimeout参数,默认是0,导致一直处于等待连接的状态,卡了好几天,导致task都没运行。