{"record":{"id":"ff8b71cba97dcb97","repo":"SignalR/SignalR","slug":"connection-ff8b71","errorCode":null,"errorMessage":"connection","messagePattern":"connection","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.AspNet.SignalR.Core/ConnectionExtensions.cs","lineNumber":26,"sourceCode":"using Microsoft.AspNet.SignalR.Infrastructure;\n\nnamespace Microsoft.AspNet.SignalR\n{\n    public static class ConnectionExtensions\n    {\n        /// <summary>\n        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a\n        /// specific connection id.\n        /// </summary>\n        /// <param name=\"connection\">The connection</param>\n        /// <param name=\"connectionId\">The connectionId to send to.</param>\n        /// <param name=\"value\">The value to publish.</param>\n        /// <returns>A task that represents when the broadcast is complete.</returns>\n        public static Task Send(this IConnection connection, string connectionId, object value)\n        {\n            if (connection == null)\n            {\n                throw new ArgumentNullException(\"connection\");\n            }\n\n            if (String.IsNullOrEmpty(connectionId))\n            {\n                throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, \"connectionId\");\n            }\n\n            var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId),\n                                                value);\n\n            return connection.Send(message);\n        }\n\n        /// <summary>\n        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a\n        /// specific connection id.\n        /// </summary>\n        /// <param name=\"connection\">The connection</param>","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/SignalR/SignalR/blob/693053b89a9e1f5ce819e3233ed159a6409de22b/src/Microsoft.AspNet.SignalR.Core/ConnectionExtensions.cs#L8-L44","documentation":"Thrown by ConnectionExtensions.Send(IConnection, string connectionId, object value) when the connection argument is null. The extension method builds a ConnectionMessage and calls connection.Send, so a null connection cannot perform the broadcast.","triggerScenarios":"Calling connection.Send(connectionId, value) as an extension method on a null IConnection reference.","commonSituations":"Static helper usage where the IConnection was never resolved from the dependency resolver, or was nulled during shutdown.","solutions":["Resolve the IConnection from GlobalHost.ConnectionManager.GetConnectionContext (or the resolver) before calling Send.","Guard the connection reference for null before invoking the extension.","Avoid calling Send after the application has shut down the connection."],"exampleFix":"// before\nvar conn = (IConnection)null;\nconn.Send(targetId, payload);\n\n// after\nvar conn = GlobalHost.ConnectionManager.GetConnection<MyPersistentConnection>().Connection;\nconn.Send(targetId, payload);","handlingStrategy":"validation","validationCode":"var connection = GlobalHost.ConnectionManager.GetConnection<MyPersistentConnection>().Connection;\nif (connection != null)\n    connection.Send(connectionId, value);","typeGuard":"if (connection is IConnection c && c != null) { c.Send(connectionId, value); }","tryCatchPattern":null,"preventionTips":["Always resolve IConnection from the ConnectionManager rather than caching a nullable reference.","Do not call Send after the host has shut down.","Null-check at the boundary before invoking the extension method."],"tags":["argumentnull","connection","send","persistent-connection","server"],"backgroundTag":null,"analyzedSha":"693053b89a9e1f5ce819e3233ed159a6409de22b","analyzedAt":"2026-08-13T22:23:59.793Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}