FTP上的应用引擎FTP使用Python允许连接但超时响应

问题描述 投票:1回答:1

您好,我尝试通过应用程序引擎在python上测试我的应用程序ftp。

在本地使用ftp,但是当我尝试连接时:

ftp://rebus-v5-prod.appspot.com:443要么ftps://rebus-v5-prod.appspot.com:443

显示给我:

状态:已建立连接,正在等待欢迎消息...错误:服务器关闭了连接

我的代码:

import os
from backend import upload_jobs
from firebase.firebase import Firebase

if not bool(os.getenv('CLOUD',False)):
    from dotenv import load_dotenv
    load_dotenv(verbose=True)
    print('LOAD ENV',os.getenv('VERSION'))
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

Firebase()
class HandleFTP(FTPHandler):
    def on_file_received(self, file):
        upload_jobs(file)
    def on_connect(self):
        print(self.remote_ip)

class Autorizer(DummyAuthorizer):
    def validate_authentication(self, username, password, handler):
        print(username,password,handler)

def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = Autorizer()

    # Define a new user having full r/w permissions and a read-only
    # anonymous user
    authorizer.add_user('user', '12345', './files', perm='elradfmwMT')
    #authorizer.add_anonymous(os.getcwd())

    # Instantiate FTP handler class
    handler = HandleFTP
    handler.authorizer = authorizer
    # Define a customized banner (string returned when client connects)
    handler.banner = "pyftpdlib based ftpd ready."
    # Specify a masquerade address and the range of ports to use for
    # passive connections.  Decomment in case you're behind a NAT.
    # handler.masquerade_address = '151.25.42.11'
    handler.passive_ports = range(60000, 65535)

    # Instantiate FTP server class and listen on 0.0.0.0:2121
    address = ('', int(os.environ.get('PORT', 2121)))
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 256
    server.max_cons_per_ip = 5

    # start ftp server
    server.serve_forever()
    server.handle_write()


if __name__ == '__main__':
    main()

App Engine YML

runtime: python
env: flex
entrypoint: python app.py

service: default

runtime_config:
  python_version: 3

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 15
  cool_down_period_sec: 180
  cpu_utilization:
    target_utilization: 0.6

resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

network:
  forwarded_ports:
    - 2121/tcp
python google-app-engine google-cloud-platform ftp ftps
1个回答
0
投票

您没有将端口443转发到您的应用程序:

© www.soinside.com 2019 - 2024. All rights reserved.