{"record":{"id":"aa00668c8ccb3bf0","repo":"stride3d/stride","slug":"invalid-ack","errorCode":null,"errorMessage":"Invalid ack","messagePattern":"Invalid ack","errorType":"exception","errorClass":"SimpleSocketException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/Network/SimpleSocket.cs","lineNumber":140,"sourceCode":"\n                Connected?.Invoke(this);\n\n                isConnected = true;\n            }\n            catch (Exception)\n            {\n                DisposeSocket();\n                throw;\n            }\n        }\n\n        private static async Task SendAndReceiveAck(TcpSocketClient socket, uint sentAck, uint expectedAck)\n        {\n            await socket.WriteStream.WriteInt32Async((int)sentAck).ConfigureAwait(false);\n            await socket.WriteStream.FlushAsync().ConfigureAwait(false);\n            var ack = (uint)await socket.ReadStream.ReadInt32Async().ConfigureAwait(false);\n            if (ack != expectedAck)\n                throw new SimpleSocketException(\"Invalid ack\");\n        }\n\n        private void SetSocket(TcpSocketClient socket)\n        {\n            this.socket = socket;\n        }\n\n        private void DisposeSocket()\n        {\n            if (this.socket != null)\n            {\n                if (isConnected)\n                {\n                    isConnected = false;\n                    Disconnected?.Invoke(this);\n                }\n\n                this.socket.Dispose();","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/Network/SimpleSocket.cs#L122-L158","documentation":"SimpleSocket.SendAndReceiveAck writes an acknowledgement value and expects the remote side to echo the exact expected ack; any mismatch throws SimpleSocketException(\"Invalid ack\"). It is a handshake integrity check on both server and client startup.","triggerScenarios":"StartServer/StartClient handshake where the peer returns an ack value different from the expected one — wrong protocol version, desynchronized stream, or a non-Stride service on the port.","commonSituations":"Client and server running mismatched library versions with different handshake formats; connecting to a wrong port where another service responds; packet interleaving from a race in connection setup.","solutions":["Ensure client and server use the same SimpleSocket protocol/version.","Verify the port actually hosts the expected socket service.","Check for concurrent handshakes racing on the same socket; serialize the connection setup.","Log both sentAck and received ack values to diagnose the mismatch."],"exampleFix":"// before\nvar client = SimpleSocket.StartClient(port); // version mismatch with server\n// after\n// align both processes to the same Stride Network package version, then\nvar client = SimpleSocket.StartClient(port);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var client = SimpleSocket.StartClient(port); }\ncatch (SimpleSocketException e) when (e.Message == \"Invalid ack\") { /* version/port mismatch: alert ops */ }","preventionTips":["Pin the same Stride Network version on client and server.","Verify the target port hosts the expected SimpleSocket service.","Avoid concurrent handshakes on a shared socket."],"tags":["network","socket","handshake","protocol"],"backgroundTag":"handshake-failed","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}