{"record":{"id":"25e0abd68715fc81","repo":"diem/diem","slug":"noise-client-error-sending-client-handshake-init","errorCode":null,"errorMessage":"noise client: error sending client handshake init message: {0}","messagePattern":"noise client: error sending client handshake init message: (.+?)","errorType":"error_code","errorClass":"NoiseHandshakeError","httpStatus":null,"severity":"error","filePath":"network/src/noise/error.rs","lineNumber":19,"sourceCode":"// Copyright (c) The Diem Core Contributors\n// SPDX-License-Identifier: Apache-2.0\n\nuse diem_crypto::noise::NoiseError;\nuse diem_types::PeerId;\nuse short_hex_str::ShortHexStr;\nuse std::io;\nuse thiserror::Error;\n\n/// Different errors than can be raised when negotiating a Noise handshake.\n#[derive(Debug, Error)]\npub enum NoiseHandshakeError {\n    #[error(\"noise client: MUST_FIX: missing remote server's public key when dialing\")]\n    MissingServerPublicKey,\n\n    #[error(\"noise client: MUST_FIX: error building handshake init message: {0}\")]\n    BuildClientHandshakeMessageFailed(NoiseError),\n\n    #[error(\"noise client: error sending client handshake init message: {0}\")]\n    ClientWriteFailed(io::Error),\n\n    #[error(\n        \"noise client: error reading server handshake response message, server \\\n         probably rejected our handshake message: {0}\"\n    )]\n    ClientReadFailed(io::Error),\n\n    #[error(\"noise client: error flushing socket after writing: {0}\")]\n    ClientFlushFailed(io::Error),\n\n    #[error(\"noise client: error finalizing secure connection: {0}\")]\n    ClientFinalizeFailed(NoiseError),\n\n    #[error(\"noise server: error reading client handshake init message: {0}\")]\n    ServerReadFailed(io::Error),\n\n    #[error(\"noise server: client peer id is malformed: {0}\")]","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/network/src/noise/error.rs#L1-L37","documentation":"NoiseHandshakeError::ClientWriteFailed wraps an io::Error that occurred while the Noise client was sending its initial handshake message over the socket. It means the write itself failed — the connection could not carry the handshake bytes — rather than a crypto or rejection issue.","triggerScenarios":"Calling write/send on the TCP (or other transport) stream during the first phase of the Noise client handshake when the socket is closed, reset, or otherwise unreadable by the OS.","commonSituations":"Server not listening or crashed mid-handshake; connection reset by peer/firewall; TLS or proxy layer terminated; network partition right after connect.","solutions":["Check the server is running and reachable at the dialed address.","Retry the dial with backoff — transient network failures commonly surface here.","Inspect the wrapped io::Error for ECONNRESET/EPIPE and verify firewall/NAT rules between client and server.","Verify the server's connection limits (max inbound peers) are not causing immediate disconnects."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async fn can_reach(addr: SocketAddr) -> bool {\n    tokio::net::TcpStream::connect(addr).await.is_ok()\n}","typeGuard":null,"tryCatchPattern":"match dial().await {\n    Err(NoiseHandshakeError::ClientWriteFailed(e)) if is_transient(&e) => {\n        backoff::retry(dial, MAX_ATTEMPTS).await\n    }\n    Err(e @ NoiseHandshakeError::ClientWriteFailed(_)) => { error!(\"fatal write failure: {}\", e); Err(e) }\n    ok => ok.map(|_| ())?,\n}\n\nfn is_transient(e: &io::Error) -> bool {\n    matches!(e.kind(), io::ErrorKind::ConnectionReset | io::ErrorKind::ConnectionAborted | io::ErrorKind::TimedOut)\n}","preventionTips":["Health-check the server before/while dialing.","Use bounded retries with exponential backoff for transient io errors.","Monitor connection limits and firewall rules between endpoints."],"tags":["rust","io","networking","noise-protocol"],"backgroundTag":"connection-reset","analyzedSha":"fc4714a8ea273b6efe8b13dbce72ea60aad9a16c","analyzedAt":"2026-09-04T21:07:05.890Z","contentChangedAt":"2026-09-04T21:07:05.890Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}