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

jamesmcwhinney
Giga Guru

Does this actually work? I thought access to the java packages was locked down as of Fuji release.

(per this thread here )

 

When I try this I get:

Attempted script access to inaccessible member denied - java.util.Properties:setProperty:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;
Background message, type:info, message: Exception caught :JavaException: java.lang.SecurityException: Illegal access to method setProperty(string,string) in class java.util.Properties

 

Thanks

FYI - for anyone interested, while access to the java packages from the instance was locked down in Fuji release, they are still accessible on the mid server.

Here is an example of how to connect via FTP from the mid server:

How to get download a file from FTP and attach to a record in ServiceNow? - Developer Community - Qu...

(May take some adjusting to use SFTP)