Unable to connect FTP via VPN

hi,
on my gateway i have an eth nic and a VPN one.
while i can connect using FTP to public IPs i can’t reach hosts in VPN, using the same code.
the script fails on the ftp.connect()
this is my code trunk:

[code]import system, sys
from ftplib import FTP
filename = ‘test.txt’
fileContent = ‘blablabla’
localFile = system.file.getTempFile(“txt”)
system.file.writeFile(localFile, “content”, 0)

addr=‘10.8.128.xxxxx’
port=21

print "Connection to "+addr

ftp = FTP()
ftp.connect(addr,int(port))
ftp.login(“xxx”,“xxx”)
print "Uploading "+filename
file = open(localFile,‘rb’)
ftp.storbinary('STOR ’ + filename, file)
ftp.quit()
file.close()[/code]

[quote]Traceback (most recent call last):
File “”, line 15, in
File “C:\Users\Supervisore\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\ftplib.py”, line 129, in connect
raise socket.error, msg
socket.error: (10061, ‘Connection refused’)

at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.doRaise(PyException.java:200)
at org.python.core.Py.makeException(Py.java:1225)
at org.python.core.Py.makeException(Py.java:1229)
at ftplib$py.connect$8(C:\Users\Supervisore\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\ftplib.py:133)
at ftplib$py.call_function(C:\Users\Supervisore\AppData\LocalLow\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\ftplib.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:166)
at org.python.core.PyFunction.__call__(PyFunction.java:338)
at org.python.core.PyMethod.__call__(PyMethod.java:139)
at org.python.pycode._pyx19.f$0(<script playground>:24)
at org.python.pycode._pyx19.call_function(<script playground>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:539)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:532)
at com.inductiveautomation.ignition.designer.gui.tools.ScriptPlayground.runScript(ScriptPlayground.java:203)
at com.inductiveautomation.ignition.designer.gui.tools.ScriptPlayground$2.actionPerformed(ScriptPlayground.java:219)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.5.3 (b1163)
Java: Sun Microsystems Inc. 1.6.0_33[/quote]

Are you running the designer on the same machine as the gateway? Unless you put your code into a gateway script it’s going to run from the machine that is running the designer or client.

:scratch:

thank you kevin. so it’s different from sql connections… ok.
in my situation i need to reach client tags informations to establish the right connection. what is the best solution to make this on a gateway script?

So the address/port that you want to FTP into come from the client or just the files to send?

i need to send a file via FTP to a remote host connected by VPN.
the file has to be generated by client scripting but only the ignition gateway is connected to the remote host.
thanx
:slight_smile:

This won’t be very easy.

You’ll need to generate the file on the clients and then insert it into a database. A gateway script will need to be watching this database table for new entries, and when a row is inserted, it takes that file and then does the FTP transfer.

not so quick but i like it very much! :thumb_left:
thank you kevin