FirebirdSQL / python3-driver

Firebird driver for Python that uses new Firebird API
https://www.firebirdsql.org/en/devel-python-driver/
MIT License
26 stars 10 forks source link

Failed to establish a connection to the server on the specified port #27

Closed ant-zuev closed 10 months ago

ant-zuev commented 10 months ago

If I specify a port value other than 3050 in server configuration, I will get an error when trying to connect to the server listening this port.

Run server on port 3051: ./firebird -a -p 3051

Check connection:

# isql -u sysdba -p masterkey localhost/3051:employee
Database: localhost/3051:employee, User: SYSDBA

Register Firebird server

from firebird.driver import connect_server, driver_config

srv_cfg = """[main_server]
host = localhost
port = 3051
user = SYSDBA
password = masterkey
"""
driver_config.register_server('main_server', srv_cfg)

Attach to 'main' server

con = connect_server('main_server')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/anton/env/lib/python3.10/site-packages/firebird/driver/core.py", line 5571, in connect_server
    svc = provider.attach_service_manager(host, spb_buf)
  File "/home/anton/env/lib/python3.10/site-packages/firebird/driver/interfaces.py", line 1302, in attach_service_manager
    self._check()
  File "/home/anton/env/lib/python3.10/site-packages/firebird/driver/interfaces.py", line 111, in _check
    raise self.__report(DatabaseError, self.status.get_errors())
firebird.driver.types.DatabaseError: Unable to complete network request to host "localhost".
-Failed to establish a connection.

I think the problem is in connect_server(). Port is not added to host: https://github.com/FirebirdSQL/python3-driver/blob/7bb33ab32b3a925e63ea478176a2537b2f35dafd/src/firebird/driver/core.py#L5557