{"record":{"id":"742169c83601c95a","repo":"micro/go-micro","slug":"s-s-s","errorCode":null,"errorMessage":"%s-%s | %s","messagePattern":"%s-%s \\| %s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/rpc_server.go","lineNumber":154,"sourceCode":"\t\t}\n\t}()\n\n\tfor {\n\t\tmsg := transport.Message{\n\t\t\tHeader: make(map[string]string),\n\t\t}\n\n\t\t// Close connection if Connection: close header was set\n\t\tif closeConn {\n\t\t\treturn\n\t\t}\n\n\t\t// Process inbound messages one at a time\n\t\tif err := sock.Recv(&msg); err != nil {\n\t\t\t// Set a global error and return.\n\t\t\t// We're saying we essentially can't\n\t\t\t// use the socket anymore\n\t\t\tgerr = errors.Wrapf(err, \"%s-%s | %s\", s.opts.Name, s.opts.Id, sock.Remote())\n\n\t\t\treturn\n\t\t}\n\n\t\t// Keep track of when to close the connection\n\t\tif c := msg.Header[\"Connection\"]; c == \"close\" {\n\t\t\tcloseConn = true\n\t\t}\n\n\t\t// Check the message header for micro message header, if so handle\n\t\t// as micro event\n\t\tif t := msg.Header[headers.Message]; len(t) > 0 {\n\t\t\t// Process the event\n\t\t\tev := newEvent(msg)\n\n\t\t\tif err := s.HandleEvent(ev.Topic())(ev); err != nil {\n\t\t\t\tmsg.Header[headers.Error] = err.Error()\n\t\t\t\tlogger.Logf(log.ErrorLevel, \"failed to handle event: %v\", err)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/server/rpc_server.go#L136-L172","documentation":"ServeConn's receive loop sets a global error when sock.Recv fails, wrapping it with the server name, ID, and the remote peer address in the format \"<name>-<id> | <remote>: <cause>\". Because a Recv failure means the socket is no longer usable, the loop returns immediately and the connection is torn down.","triggerScenarios":"Any failure receiving from the client socket during message processing: the client disconnected/closed the connection, network timeout, socket closed by shutdown, or a transport-level error (e.g. connection reset by peer).","commonSituations":"Client crash or abrupt disconnect mid-request; client idle timeouts; load balancer killing long-lived connections; server shutdown closing sockets; network partitions between client and server.","solutions":["Check the wrapped cause (errors.Cause) — ErrConnClosed / io.EOF are normal disconnects","Treat these as client-side lifecycle events and log at debug rather than error for normal closes","Investigate client idle/keepalive settings if disconnects are frequent","Ensure the transport has adequate timeouts for long-running requests","Verify load balancers/proxies aren't terminating idle connections"],"exampleFix":"// before\n// server logs noisy errors on every normal client disconnect\nlog.Errorf(\"%v\", gerr)\n// after\ncause := errors.Cause(err)\nif errors.Is(cause, io.EOF) || errors.Is(cause, transport.ErrConnClosed) {\n    log.Debugf(\"client %s disconnected\", sock.Remote())\n} else {\n    log.Errorf(\"%v\", gerr)\n}","handlingStrategy":"try-catch","validationCode":"// client side: keepalive so the server doesn't see unexpected dead peers\nsock.SetTimeout(10 * time.Second)\n// send a close header when done\nmsg.Header[\"Connection\"] = \"close\"","typeGuard":null,"tryCatchPattern":"if err := server.Start(); err != nil { ... }\n// server-side: wrap the ServeConn error and classify\ngerr := errors.Wrapf(err, \"%s-%s | %s\", name, id, remote)\nif errors.Is(errors.Cause(err), io.EOF) || errors.Is(errors.Cause(err), transport.ErrConnClosed) {\n    log.Debugf(\"peer %s disconnected\", remote)\n} else {\n    log.Errorf(\"%v\", gerr)\n}","preventionTips":["Configure client keepalive/idle timeouts shorter than any LB/proxy idle timeout","Send Connection: close header on graceful client shutdown","Classify recv errors: EOF/reset are routine, others need investigation","Use transport-level health checks to detect dying connections early"],"tags":["rpc","socket","connection","server"],"backgroundTag":"socket-recv-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}