dotnetcore/CAP · error · PublisherSentFailedException

NATS message send failed, no consumer reply!

Error message

NATS message send failed, no consumer reply!

What it means

A generic sentinel thrown by the NATS transport's SendAsync when a JetStream PublishAsync completes without a confirmed sequence number (resp.Seq == 0), meaning the message was not acknowledged by the stream — usually because the stream/consumer bound to the subject does not exist or is not properly configured. The input at fault is the JetStream subject derived from the message name.

Solutions

  1. Ensure the JetStream stream that captures the publish subject exists (create it via nats stream add or programmatically) before publishing.
  2. Verify _jetStreamOptions and the stream subject mapping cover the message name being published to.
  3. Check the NATS connection and account permissions; a publish to a subject with no interest or insufficient rights yields no ack, triggering this error.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/DotNetCore.CAP.NATS/ITransport.NATS.cs:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnetcore/CAP@e52b8508e5 (2026-09-14). Data as JSON: /api/errors/ec10227af668d6e9. Report an issue: GitHub.

Appendix: source

Thrown at src/DotNetCore.CAP.NATS/ITransport.NATS.cs:56

            foreach (var header in message.Headers)
            {
                msg.Header[header.Key] = header.Value;
            }

            var js = connection.CreateJetStreamContext(_jetStreamOptions);

            var builder = PublishOptions.Builder().WithMessageId(message.GetId());

            var resp = await js.PublishAsync(msg, builder.Build());

            if (resp.Seq > 0)
            {
                _logger.LogDebug($"NATS stream message [{message.GetName()}] has been published.");

                return OperateResult.Success;
            }

            throw new PublisherSentFailedException("NATS message send failed, no consumer reply!");
        }
        catch (Exception ex)
        {
            var warpEx = new PublisherSentFailedException(ex.Message, ex);

            return OperateResult.Failed(warpEx);
        }
        finally
        {
            _connectionPool.Return(connection);
        }
    }
}

View on GitHub (pinned to e52b8508e5)