SFTP connection java.net.SocketTimeoutException: Read timed out

Michael Dziubin
Kilo Contributor

I'm trying to establish SFTP connection in SNOW in order to send some files, I'm testing my script in "Scripts - Background" tab, that's how the code looks like:

try {
		var pt = new Packages.java.util.Properties();
		pt.setProperty("connection.host", "host");
		pt.setProperty("connection.port", 22);
		pt.setProperty("user.login", "user");
		pt.setProperty("user.password", "pass");
		pt.setProperty("connection.type", "AUTH_SSL_FTP_CONNECTION");
		pt.setProperty("connection.timeout", "6000");
		pt.setProperty("connection.passive", "false");
		var connection = Packages.org.ftp4che.FTPConnectionFactory.getInstance(pt);
		
		gs.log("Starting connection");
		
		connection.connect();
		gs.log("Connected!!!!!");
} catch (e) {
			gs.log("[FTP] e: " + e);
			gs.log("[FTP] Line number: " + e.lineNumber);
			gs.log("[FTP] Source: " + e.sourceName);
			gs.log("[FTP] Name: " + e.name);
			gs.log("[FTP] Message: " + e.message);
}

But whatever configuration I try I'm always getting the same error:

*** Script: [FTP] e: java.net.SocketTimeoutException: Read timed out
*** Script: [FTP] Line number: undefined
*** Script: [FTP] Source: undefined
*** Script: [FTP] Name: undefined


I though that it's caused because of some kind of firewall or other security measure but I can clearly establish SFTP connection from the instance server without a problem so why can't I connect from SNOW?

6 REPLIES 6

Shashikant Yada
Tera Guru

I guess its the issue with the Timeout, you need to increase the timeout value

https://help.avalara.com/Frequently_Asked_Questions/001/How_do_I_resolve_a_java.net.SocketTimeoutException%3A_Read_timed_out%3F

No, that's not the cause. Even when I set the timeout to 60 minutes the same error happens.

Can you check the number of connection to that SFTP, there might be some limit for the connection

I tried two different SFTPs and the same error.