{"record":{"id":"1ee93f27a3686dda","repo":"dotnet/aspnetcore","slug":"there-are-no-callbacks-registered-for-the-method","errorCode":null,"errorMessage":"There are no callbacks registered for the method '%s'.","messagePattern":"There are no callbacks registered for the method '(.+?)'\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/HubConnection.java","lineNumber":1647,"sourceCode":"        public Type getReturnType(String invocationId) {\n            InvocationRequest irq = getInvocation(invocationId);\n            if (irq == null) {\n                return null;\n            }\n\n            return irq.getReturnType();\n        }\n\n        @Override\n        public List<Type> getParameterTypes(String methodName) {\n            List<InvocationHandler> handlers = connection.handlers.get(methodName);\n            if (handlers == null) {\n                logger.warn(\"Failed to find handler for '{}' method.\", methodName);\n                return emptyArray;\n            }\n\n            if (handlers.isEmpty()) {\n                throw new RuntimeException(String.format(\"There are no callbacks registered for the method '%s'.\", methodName));\n            }\n\n            return handlers.get(0).getTypes();\n        }\n\n        private void errorHandshake(Exception error) {\n            lock.lock();\n            try {\n                // If onError is called on a completed subject the global error handler is called\n                if (!(handshakeResponseSubject.hasComplete() || handshakeResponseSubject.hasThrowable())) {\n                    handshakeResponseSubject.onError(error);\n                }\n            } finally {\n                lock.unlock();\n            }\n        }\n    }\n","sourceCodeStart":1629,"sourceCodeEnd":1665,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/HubConnection.java#L1629-L1665","documentation":"Inside the HubConnection binder, getParameterTypes(methodName) is called by the protocol layer to deserialize an inbound server->client InvocationMessage. If handlers were registered for the method name but the list is empty (a registration bug), the binder cannot determine parameter types and throws. A null handler list is handled separately (returns emptyArray with a warning); only a non-null but empty list triggers this throw.","triggerScenarios":"Server invokes a client method for which hub.on(method, ...) was called with an action that got removed/never set, leaving an empty List<InvocationHandler> in the handlers map. The binder then cannot read argument types for deserialization.","commonSituations":"A handler was registered then unregistered but the empty list entry was not removed from the map; misuse of the on() API leaving a placeholder; reflection-based handler registration that produced zero handlers.","solutions":["Ensure hub.on(method, action) actually adds a non-null action; verify with hub.off() then re-on() if the list may be stale.","After unregistering handlers, call hub.off(method) to fully remove the entry rather than leaving an empty list.","Upgrade the client - this is a defensive throw for an internal invariant; if hit with correct on() usage, file an issue."],"exampleFix":"// before\nhub.on(\"Update\", null); // produces empty handler list\n\n// after\nhub.on(\"Update\", msg -> { /* handle */ });\n// to remove:\nhub.remove(\"Update\");","handlingStrategy":"validation","validationCode":"// Before relying on a handler, ensure it is actually registered.\n// (No public getter exists; track registrations yourself.)\nSet<String> registeredMethods = ConcurrentHashMap.newKeySet();\nhub.on(\"Update\", msg -> { registeredMethods.add(\"Update\"); /*handle*/ registeredMethods.add(\"Update\"); });\n// Server will only invoke methods present in this set with a non-empty handler.","typeGuard":null,"tryCatchPattern":"// The throw surfaces during message binding. If hit, the inbound message is dropped.\n// Log it and verify your on() registrations.\nhub.onClosed(ex -> {\n  if (ex != null && ex.getMessage().contains(\"no callbacks registered\")) {\n    log.error(\"Handler missing for server-invoked method; re-register and reconnect\");\n  }\n});","preventionTips":["Always pass a non-null action to hub.on(method, action).","Use hub.remove(method) (not partial removal) to clear handlers cleanly.","Add an integration test that has the server invoke each registered client method."],"tags":["signalr","java","binding","handler","internal-invariant"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}