Skip to content

Commit 9ecb283

Browse files
committed
Improve logging around connection establishment
It will help diagnose long running TLS handshakes.
1 parent e82457a commit 9ecb283

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

driver/src/main/java/org/neo4j/driver/internal/net/SocketClient.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,17 @@ public void start()
120120
{
121121
try
122122
{
123-
logger.debug( "~~ [CONNECT] %s", address );
123+
logger.debug( "Connecting to %s, secure: %s", address, securityPlan.requiresEncryption() );
124124
if( channel == null )
125125
{
126126
setChannel( ChannelFactory.create( address, securityPlan, timeoutMillis, logger ) );
127+
logger.debug( "Connected to %s, secure: %s", address, securityPlan.requiresEncryption() );
127128
}
128-
setProtocol( negotiateProtocol() );
129+
130+
logger.debug( "Negotiating protocol with %s", address );
131+
SocketProtocol protocol = negotiateProtocol();
132+
setProtocol( protocol );
133+
logger.debug( "Selected protocol %s with %s", protocol.getClass(), address );
129134
}
130135
catch ( ConnectException e )
131136
{
@@ -206,7 +211,7 @@ public void stop()
206211
{
207212
channel.close();
208213
setChannel( null );
209-
logger.debug( "~~ [DISCONNECT]" );
214+
logger.debug( "Disconnected from %s", address );
210215
}
211216
}
212217
catch ( IOException e )

driver/src/main/java/org/neo4j/driver/internal/security/TLSSocketChannel.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public static TLSSocketChannel create( ByteChannel channel, Logger logger, SSLEn
121121
*/
122122
private void runHandshake() throws IOException
123123
{
124-
logger.debug( "~~ [OPENING SECURE CHANNEL]" );
124+
logger.debug( "Running TLS handshake" );
125+
125126
sslEngine.beginHandshake();
126127
HandshakeStatus handshakeStatus = sslEngine.getHandshakeStatus();
127128
while ( handshakeStatus != FINISHED && handshakeStatus != NOT_HANDSHAKING )
@@ -142,6 +143,8 @@ private void runHandshake() throws IOException
142143
break;
143144
}
144145
}
146+
147+
logger.debug( "TLS handshake completed" );
145148
}
146149

147150
private HandshakeStatus runDelegatedTasks()
@@ -479,7 +482,7 @@ public void close() throws IOException
479482
}
480483
// Close transport
481484
channel.close();
482-
logger.debug( "~~ [CLOSED SECURE CHANNEL]" );
485+
logger.debug( "Closed secure channel" );
483486
}
484487
catch ( IOException e )
485488
{

0 commit comments

Comments
 (0)