SignalR/SignalR · error · ArgumentNullException
connection
Error message
connection
What it means
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.
Source
Thrown at src/Microsoft.AspNet.SignalR.Core/ConnectionExtensions.cs:26
using Microsoft.AspNet.SignalR.Infrastructure;
namespace Microsoft.AspNet.SignalR
{
public static class ConnectionExtensions
{
/// <summary>
/// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
/// specific connection id.
/// </summary>
/// <param name="connection">The connection</param>
/// <param name="connectionId">The connectionId to send to.</param>
/// <param name="value">The value to publish.</param>
/// <returns>A task that represents when the broadcast is complete.</returns>
public static Task Send(this IConnection connection, string connectionId, object value)
{
if (connection == null)
{
throw new ArgumentNullException("connection");
}
if (String.IsNullOrEmpty(connectionId))
{
throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "connectionId");
}
var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId),
value);
return connection.Send(message);
}
/// <summary>
/// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
/// specific connection id.
/// </summary>
/// <param name="connection">The connection</param>View on GitHub (pinned to 693053b89a)
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.
Example fix
// before var conn = (IConnection)null; conn.Send(targetId, payload); // after var conn = GlobalHost.ConnectionManager.GetConnection<MyPersistentConnection>().Connection; conn.Send(targetId, payload);
Defensive patterns
Strategy: validation
Validate before calling
var connection = GlobalHost.ConnectionManager.GetConnection<MyPersistentConnection>().Connection;
if (connection != null)
connection.Send(connectionId, value); Type guard
if (connection is IConnection c && c != null) { c.Send(connectionId, value); } Prevention
- 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.
When it happens
Trigger: Calling connection.Send(connectionId, value) as an extension method on a null IConnection reference.
Common situations: Static helper usage where the IConnection was never resolved from the dependency resolver, or was nulled during shutdown.
Related errors
AI-assisted analysis of SignalR/SignalR@693053b89a (2026-08-13).
Data as JSON: /api/errors/ff8b71cba97dcb97.
Report an issue: GitHub.