# Unable to connect FTP via VPN

**URL:** <https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597>\
**Category:** Ignition\
**Created:** [May 29, 2013, 12:32pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597 "2013-05-29T12:32:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [May 29, 2013, 12:32pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/1 "2013-05-29T12:32:04Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 29, 2013, 1:27pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/2 "2013-05-29T13:27:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [May 29, 2013, 2:23pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/3 "2013-05-29T14:23:26Z")

</div>

![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":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?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 29, 2013, 3:26pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/4 "2013-05-29T15:26:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [May 29, 2013, 3:40pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/5 "2013-05-29T15:40:08Z")

</div>

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  
🙂

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 29, 2013, 4:04pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/6 "2013-05-29T16:04:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [May 29, 2013, 4:37pm UTC](https://forum.inductiveautomation.com/t/unable-to-connect-ftp-via-vpn/6597/7 "2013-05-29T16:37:39Z")

</div>

not so quick but i like it very much! ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")  
thank you kevin
