Disconnect reason for authentication
See original GitHub issuewith AuthenticationEnabled you get a instand unknown disconnect if you send to server before the AuthenticationSucceeded event fired.
so here you get a disconnect because we send a message before auth event.
TcpClient.Connect();
if (TcpClient != null && TcpClient.Connected)
TcpClient.Send(data, meta);
[WatsonTcpClient] connecting with SSL to 192.168.2.170:59141 [WatsonTcpClient] connected to 192.168.2.170:59141 –> Send is here [WatsonMessage] found header demarcation [WatsonMessage] header processing complete {“s”:“AuthRequired”,“len”:0} [WatsonTcpClient] authentication required by server; please authenticate using pre-shared key [WatsonMessage] non-graceful termination by peer [WatsonTcpClient] disconnect detected
with waiting for AuthenticationSucceeded event and then send the first messages to server you get: [WatsonTcpClient] connecting with SSL to 192.168.2.170:59141 [WatsonTcpClient] connected to 192.168.2.170:59141 [WatsonMessage] found header demarcation [WatsonMessage] header processing complete {“s”:“AuthRequired”,“len”:0} [WatsonTcpClient] authentication required by server; please authenticate using pre-shared key [WatsonMessage] found header demarcation [WatsonMessage] header processing complete{“s”:“AuthSuccess”,“len”:25} [WatsonTcpClient] authentication successful –> Send is here and working
it is logical and not an error, but if you do not recognize it, the reason for the disconnect is difficult to find. maybe you have an idea to some error message, or a new public bool Authenticated { get; private set; }
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Ok - so the reason this is happening is that a message is arriving without validation authentication. The message contains data that never gets read, meaning, when the server DataReceiver loop continues, it’s expecting to find the start of a new message, but there’s data from the past message waiting to be read in the stream.
I’m going to change the behavior such that on authentication failure, the server proactively disconnects and disposes the client rather than leaving the connection in-tact. Leaving it in-tact actually creates a DoS vulnerability in that anyone could connect and just keep firing messages at the server.
Hi @Jyck please check out the following and re-open if any issues. Thanks for filing this!
NuGet: https://www.nuget.org/packages/WatsonTcp/4.8.10 Commit: https://github.com/jchristn/WatsonTcp/commit/f7d1242fc93ec882f4f857e29acb14841616c180