Skip to content

(2.12) [ADD] no responders return the original subject#5250

Merged
neilalexander merged 1 commit intonats-io:mainfrom
ramonberrutti:return-subject-on-request-fail
Aug 14, 2025
Merged

(2.12) [ADD] no responders return the original subject#5250
neilalexander merged 1 commit intonats-io:mainfrom
ramonberrutti:return-subject-on-request-fail

Conversation

@ramonberrutti
Copy link
Copy Markdown
Contributor

Using Request-Reply is very useful.

When using Request with multiple replays, it is difficult to know when the requester loses interest in the replays.
Today, Nats returns an error 503 to the replay subject without any extra information.

Signed-off-by: Ramon Berrutti ramonberrutti@gmail.com

@ramonberrutti ramonberrutti requested a review from a team as a code owner March 26, 2024 21:23
t.Fatalf("Did not get a match for %q", l)
}
checkPayload(cr, []byte("NATS/1.0 503\r\n\r\n"), t)
checkPayload(cr, []byte("NATS/1.0 503\r\nNats-Subject: foo\r\n\r\n\r\n"), t)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also checking that the body is empty.

if sub := c.subForReply(c.pa.reply); sub != nil {
proto := fmt.Sprintf("HMSG %s %s 16 16\r\nNATS/1.0 503\r\n\r\n\r\n", c.pa.reply, sub.sid)
hdrLen := 32 /* header without the subject */ + len(c.pa.subject)
proto := fmt.Sprintf("HMSG %s %s %d %d\r\nNATS/1.0 503\r\nNats-Subject: %s\r\n\r\n\r\n", c.pa.reply, sub.sid, hdrLen, hdrLen, c.pa.subject)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked Nats-Subject as the header name because it is used elsewhere.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case it means the original subject the current message was published as - not sure we want to use that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the only way you would get this is if you are responding and adding a reply subject - which means that when the server answers with no responders, you know what the reply subject that you published a response to is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why I need the feature:

  • Service A: pub reply to MyService.Endpoint with a _INBOX.
  • Service B: sub to MyService.Endpoint and publish multiple times (grpc server stream) to the client _INBOX.hash with a reply option to MyService.Endpoint.
  • The server tracks each inbox in a hashmap and deletes it when it receives a 503.

To resolve the issue, I'm doing something similar but my service subscribe to MyService.> and setting the reply as: MyService.Endpoint., I also could have two subscriptions, one for MyService.Endpoint and another for MyService.Endpoint.>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @aricart. Can we review and consider this change?

@github-actions github-actions bot added the stale This issue has had no activity in a while label May 23, 2024
@neilalexander neilalexander added 2.12+ Features for 2.12 and beyond and removed stale This issue has had no activity in a while labels May 16, 2025
@neilalexander
Copy link
Copy Markdown
Member

@ripienaar Seems reasonable for me for a 2.12 change, WDYT?

@ripienaar
Copy link
Copy Markdown
Contributor

Yeah I thinking does make sense

@aricart
Copy link
Copy Markdown
Member

aricart commented May 22, 2025

at some point I remember Matthias had said there was a mechanism to figure out if there was interest on a subject, is this still true or was this retracted?

@neilalexander
Copy link
Copy Markdown
Member

Hey @ramonberrutti, would you mind rebasing on top of latest main?

@neilalexander neilalexander changed the title [ADD] no responders return the original subject (2.12) [ADD] no responders return the original subject Jul 21, 2025
@ramonberrutti ramonberrutti force-pushed the return-subject-on-request-fail branch from 92e2b7d to abebcc4 Compare August 14, 2025 11:07
Signed-off-by: Ramon Berrutti <ramonberrutti@gmail.com>
@ramonberrutti ramonberrutti force-pushed the return-subject-on-request-fail branch from abebcc4 to 362769a Compare August 14, 2025 11:08
@ramonberrutti
Copy link
Copy Markdown
Contributor Author

Hey @ramonberrutti, would you mind rebasing on top of latest main?

Sorry for the delay, done.

Added the Signed-off too.

Copy link
Copy Markdown
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@neilalexander neilalexander merged commit 964cf38 into nats-io:main Aug 14, 2025
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.12+ Features for 2.12 and beyond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants