You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using a NATS server with JetStream configured.
When we want to do a PullSubscribe for a wildcard subject we encode the subject to become the Durable name of the consumer. This results in a string that doesn't contain the wildcards but it introduces '%'. This should be valid since it is in the ASCII printable range and differs from the wildcard characters.
Although when we subscription and fetch the messages we get no results in return. If we use a consumername that doesn't include any '%' we get the correct results.
You can reproduce this with the following procedure:
Enable JetStream on the NATS server.
I created a JetStream with the following configuration (yellow highlighted items differ from default):
I published a message: nats pub "test.1" "someData"
I created a small test program to simulate this. Commenting one of the lines with the // <-- SWAP BETWEEN THESE TWO LINES comment enables you to simulate a working and broken scenario.
using NATS.Client;using NATS.Client.JetStream;classProgram{staticvoidMain(string[]args){// ConnectvarconnectionFactory=new ConnectionFactory();varoptions= ConnectionFactory.GetDefaultOptions();
options.DisconnectedEventHandler +=(sender,eventArgs)=>{ Console.WriteLine("ERROR");};
options.Url ="localhost:4222";varconnection= connectionFactory.CreateConnection(options);while(connection.State != ConnState.CONNECTED){
Task.Delay(100);}// Subscribevarcontext= connection.CreateJetStreamContext();varconsumerName="Test%123";// <-- SWAP BETWEEN THESE TWO LINES//var consumerName = "Test123"; // <-- SWAP BETWEEN THESE TWO LINESvarsubOptions= PullSubscribeOptions.Builder().WithDurable(consumerName).Build();varsub= context.PullSubscribe("test.*", subOptions);IList<Msg>?messages= sub.Fetch(10,1000);// Cleanup
sub.Unsubscribe();IJetStreamManagement?jsm= connection.CreateJetStreamManagementContext();
jsm?.DeleteConsumer("test", consumerName);
Console.WriteLine($"Number of received messages: {messages.Count}");}}
No error is seen except a disconnect and reconnect that happens in case a '%' is present in the consumer name.
If the Consumer had a name containing `%`, it could result in the reply
subject failing to format with `fmt.Sprintf`, as the `%` was not
properly escaped with `%%`.
Resolves#4038
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Hi,
We are using a NATS server with JetStream configured.
When we want to do a PullSubscribe for a wildcard subject we encode the subject to become the Durable name of the consumer. This results in a string that doesn't contain the wildcards but it introduces '%'. This should be valid since it is in the ASCII printable range and differs from the wildcard characters.
Although when we subscription and fetch the messages we get no results in return. If we use a consumername that doesn't include any '%' we get the correct results.
You can reproduce this with the following procedure:
Enable JetStream on the NATS server.
I created a JetStream with the following configuration (yellow highlighted items differ from default):
I published a message:
nats pub "test.1" "someData"
I created a small test program to simulate this. Commenting one of the lines with the
// <-- SWAP BETWEEN THESE TWO LINES
comment enables you to simulate a working and broken scenario.No error is seen except a disconnect and reconnect that happens in case a '%' is present in the consumer name.
Is collected these logs:
This line in the log above looks suspicious if you compare it to the log of the working situation (note the
%d
):VS
Is this expected behavior, are we doing something wrong, or is this a bug?
Thanks in advance for the support!
Greetings,
Frederic
The text was updated successfully, but these errors were encountered: