{"record":{"id":"a361daff0ccc826d","repo":"geektutu/7days-golang","slug":"rpc-server-can-t-find-method-a361da","errorCode":null,"errorMessage":"rpc server: can't find method ","messagePattern":"rpc server: can't find method ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gee-rpc/day6-load-balance/server.go","lineNumber":128,"sourceCode":"\treturn &h, nil\n}\n\nfunc (server *Server) findService(serviceMethod string) (svc *service, mtype *methodType, err error) {\n\tdot := strings.LastIndex(serviceMethod, \".\")\n\tif dot < 0 {\n\t\terr = errors.New(\"rpc server: service/method request ill-formed: \" + serviceMethod)\n\t\treturn\n\t}\n\tserviceName, methodName := serviceMethod[:dot], serviceMethod[dot+1:]\n\tsvci, ok := server.serviceMap.Load(serviceName)\n\tif !ok {\n\t\terr = errors.New(\"rpc server: can't find service \" + serviceName)\n\t\treturn\n\t}\n\tsvc = svci.(*service)\n\tmtype = svc.method[methodName]\n\tif mtype == nil {\n\t\terr = errors.New(\"rpc server: can't find method \" + methodName)\n\t}\n\treturn\n}\n\nfunc (server *Server) readRequest(cc codec.Codec) (*request, error) {\n\th, err := server.readRequestHeader(cc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq := &request{h: h}\n\treq.svc, req.mtype, err = server.findService(h.ServiceMethod)\n\tif err != nil {\n\t\treturn req, err\n\t}\n\treq.argv = req.mtype.newArgv()\n\treq.replyv = req.mtype.newReplyv()\n\n\t// make sure that argvi is a pointer, ReadBody need a pointer as parameter","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-rpc/day6-load-balance/server.go#L110-L146","documentation":"The service was found, but the method name has no registered methodType in svc.method. gee-rpc only publishes methods matching its criteria (exactly two args, second a pointer, one error return, all exported). This error means the requested method either does not exist or did not pass registration filtering.","triggerScenarios":"Client requests \"Foo.Sum\" but Foo has no exported method Sum, or Sum has an incompatible signature (wrong arg count, no pointer receiver arg, missing error return), or the method is unexported (lowercase).","commonSituations":"Typo in the method name, refactoring/renaming the server-side method without updating clients, calling an unexported method, or a signature change (e.g. adding a ctx or returning a value) that silently removed the method from the published set.","solutions":["Correct the method name in the client call to match the exported Go method exactly (case-sensitive).","Make the server method conform: func (f *Foo) Method(arg Req, reply *Resp) error.","Ensure the method is exported (capitalized) and the receiver is a pointer type registered via Register."],"exampleFix":"// before\nfunc (f *Foo) Sum(a Args) Result { ... }\n// after\nfunc (f *Foo) Sum(a Args, reply *Result) error { ... }","handlingStrategy":"validation","validationCode":"// ensure signature matches what gee-rpc publishes\nvar _ interface{ Sum(Args, *Result) error } = (*Foo)(nil)\nif !strings.HasPrefix(\"Sum\", strings.ToUpper(\"Sum\")[:1]) { /* method must be exported */ }","typeGuard":null,"tryCatchPattern":"if err := client.Call(ctx, \"Foo.Sum\", args, reply); err != nil && strings.Contains(err.Error(), \"can't find method\") { return fmt.Errorf(\"check method name/signature: %w\", err) }","preventionTips":["Use an interface assertion on the server to pin method signatures.","Keep method names exported and stable; search-rename across client and server.","Remember only methods with (arg, *reply) error signatures are published."],"tags":["rpc","method-not-found","reflection"],"backgroundTag":"rpc-method-not-found","analyzedSha":"cf3644382101dc13e7fd92e8f5c66cabc51bcd3b","analyzedAt":"2026-09-03T18:31:24.087Z","contentChangedAt":"2026-09-03T18:31:24.087Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}