简体   繁体   中英

AssertionError: PORT is not a number (in Python)

when i using ssh tunnel to access mySQL db, why always show this error on remote_bind_address ?

AssertionError: PORT is not a number

here is my code:

with SSHTunnelForwarder(
        (self.ssh_host, self.ssh_port),  # Remote server IP and SSH port
        ssh_username=self.ssh_username,
        ssh_private_key=self.ssh_pkey,
        remote_bind_address=(self.host_mysql, self.port_mysql)
        ) as server:
        server.start()  # start ssh sever
        print('Server connected via SSH') 
        local_port = str(server.local_bind_port)

anyone can help me? thanks before

Probably the error occurs because the port you provide is of type string and not int. Check it by printing type(self.port_mysql) before the problematic line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM