Recently, the number of SFTP connections for online monitoring frequently exceeds the threshold. By restarting a system, the number of connections decreases rapidly, and the system can be restored to normal. The initial conclusion is that the application connection is not closed. Stack length is checked by IDE global search, SFTP connection uses JSCH package, there are some function points that use SFTP connection and do not close, or do not close properly in finally statement block. After the rectification went online, SFTP is still off the charts…… After the operation and maintenance mentality is broken, operation and maintenance actively wrote a SFTP connection monitoring, when the connection is more than 5 minutes idle will actively disconnect. But this is only temporary processing, the real reason is certainly not the normal closure of the application, so serious investigation under the program, finally found out the culprit. Here is the sample code:

At this point, the problem of online SFTP connection has been solved and I can have a good sleep at ease. At the same time, I also feel that our colleagues are too awesome and let me increase my knowledge.