D
D
Dmitry Tereschenko2019-11-18 16:36:11
Python
Dmitry Tereschenko, 2019-11-18 16:36:11

How to solve the problem with deploying to Travis-CI via FTP [TimeoutError: Connection timed out]?

With Travis-CI, I want to implement the following scenario:

  • Running Tests
  • Building the application in production view
  • Server Deployment

There are no problems with the first and second points.
-------
Content of .travis.yml :
language: python
branches:
  only:
    - project/feature/CI&CD
python:
    - "3.7"
env:
    - DJANGO_VERSION=2.2.6
install:
    - pip install -q Django==$DJANGO_VERSION
    - sh install.sh
script: sh test.sh
after_success: 
    - sh build.sh
    - python deploy.py

-------
About the third in more detail:
  • Deployment follows the principle of delivering files to an FTP server
  • FTP Server configured on Windows Server 2012 via IIS
  • The FTP client is the Python library 'ftplib'

-------
When Travis-CI runs the following script (simplified version):
import os
import ftplib

ftp = ftplib.FTP()
print(ftp.connect(HOST, PORT))
print(ftp.login(os.environ['FTP_USER'], os.environ['FTP_PASSWORD']))

if 'mainService-test' not in ftp.nlst():
    ftp.mkd('mainService-test')

Crashes with an error:
220 Microsoft FTP Service
230 User logged in.
Traceback (most recent call last):
  File "deploy.py", line 151, in <module>
    if 'mainService-test' not in ftp.nlst():
  File "/opt/python/3.7.1/lib/python3.7/ftplib.py", line 559, in nlst
    self.retrlines(cmd, files.append)
  File "/opt/python/3.7.1/lib/python3.7/ftplib.py", line 468, in retrlines
    with self.transfercmd(cmd) as conn, \
  File "/opt/python/3.7.1/lib/python3.7/ftplib.py", line 399, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/opt/python/3.7.1/lib/python3.7/ftplib.py", line 361, in ntransfercmd
    source_address=self.source_address)
  File "/opt/python/3.7.1/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/opt/python/3.7.1/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

Those. there are no connection problems. The error occurs only on commands that require any data from the server.
When I run the same script on my machine, everything works!
-------
I would be grateful for any help provided!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Karasik, 2019-11-18
@vitaly_il1

When I run the same script on my machine, everything works!

Maybe your ftp server is only open to the internal network?

D
Dimonchik, 2019-11-18
@dimonchik2013

Those. there are no connection problems. The error occurs only on commands that require any data from the server.
When I run the same script on my machine, everything works!

it is necessary to rewrite in network terms
and, you see, you yourself will answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question