Skip to content

Commit 096c42b

Browse files
authored
Log failed attempts of opening a connection (#609)
Backport of #608
1 parent 2e161bd commit 096c42b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

neo4j/io/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,14 @@ def connect(address, *, timeout, custom_resolver, ssl_context, keep_alive):
13171317
s = _secure(s, resolved_address.host_name, ssl_context)
13181318
return _handshake(s, resolved_address)
13191319
except (BoltError, DriverError, OSError) as error:
1320+
try:
1321+
local_port = s.getsockname()[1]
1322+
except (OSError, AttributeError):
1323+
local_port = 0
1324+
err_str = error.__class__.__name__
1325+
if str(error):
1326+
err_str += ": " + str(error)
1327+
log.debug("[#%04X] C: <CONNECTION FAILED> %s", local_port, err_str)
13201328
if s:
13211329
_close_socket(s)
13221330
errors.append(error)

0 commit comments

Comments
 (0)