-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I was noticing some weird behavior in the C# driver with the connection pooling code. I noticed, when Connection.Close() is called, any attempts to .Reconnect(), the reconnect always fails even if the TCP physical socket connection was okay.
I think this is due some internal Handshake state that is not being .reset() when the reconnect is attempted.
Handshake.java
public Handshake(String username, String password) {
this.username = username;
this.password = password;
this.state = new InitialState(username, password);
}
public void reset() {
this.state = new InitialState(this.username, this.password);
}
And there's some code here that kinda sits here except, on the 2nd time around, the Handshake was finished from the 1st attempt. 🎱
void connect(Handshake handshake){
....
while(!handshake.isFinished()) {
if (toWrite.isPresent()) {
write(toWrite.get());
}
String serverMsg = readNullTerminatedString(deadline);
toWrite = handshake.nextMessage(serverMsg);
}
....
}
So, the reconnect results in no re-authentication...
Handshake.reset() is nowhere to be found in Connection.java or in SocketWrapper.java
The pythin 🐍 code seems to Handshake.reset() in something like ConnectionInstance?
My fix in the C# driver is in SocketWrapper.cs / UnitTest. _I think_ this would be the right place for the reset. Also, seems to have resolved my .Reconnect issue in the C# driver. 😸
Let me knoooooooo what your thinking and I'll submit a PR for ya.
Muchas gracias,
Brian