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
import*asnatsfrom'nats';import{consumerOpts,StringCodec}from'nats';constcodec=StringCodec();(async()=>{constserver=awaitnats.connect({servers: 'localhost:4222',user: 'server',pass: 'a',});// Creating streams, note that we create them// from the 'server' connection, which is part of the// account exporting both stream and serviceconstjsm=awaitserver.jetstreamManager();awaitjsm.streams.add({name: 'requests',subjects: ['requests.>'],});awaitjsm.streams.add({name: 'deliveries',subjects: ['deliver.>'],});// Server subscribe to messages from clientconstopts=consumerOpts();opts.deliverTo('here');opts.ackAll();constsaSub=awaitserver.jetstream().subscribe('requests.>',opts);(async()=>{forawait(constmsgofsaSub){console.log('client to server msg on '+msg.subject,codec.decode(msg.data),);}})();// Clientconstclient=awaitnats.connect({servers: 'localhost:4222',user: 'client-1',pass: 'b',});constclientJsm=awaitclient.jetstreamManager();awaitclientJsm.streams.add({name: 'client-1-deliveries',mirror: {name: 'deliveries',filter_subject: 'deliver.client-1.>',external: {api: '[email protected]',deliver: 'deliver.client-1',},},});// Client publishes a message for the server// This works and is correctly retrieved by the serverawaitclient.jetstream().publish('requests.client-1.hello',codec.encode('hello from client'));constoptsClient=consumerOpts();optsClient.deliverTo('here');optsClient.ackAll();// Setup a subscription for the client to listen for server messagesconstcsub=awaitclient.jetstream().subscribe('deliver.client-1.>',optsClient);(async()=>{forawait(constmsgofcsub){console.log('server to client message',codec.decode(msg.data));}})();// --> error: no stream matches subject})();
It prints the following
client to server msg on requests.client-1.hello hello from client
Error: no stream matches subject
The problem is that I have a No stream matches subject when the client-1 tries to create its subscription.
Mirror streams can not have any subject set so I do not really understand where my error lies.
Thanks a lot for your help !
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to setup Jetstream cross account on a single Nats node following this tutorial. My configuration is the following:
I'm testing it with a small javascript script:
It prints the following
The problem is that I have a
No stream matches subject
when the client-1 tries to create its subscription.Mirror streams can not have any subject set so I do not really understand where my error lies.
Thanks a lot for your help !
Beta Was this translation helpful? Give feedback.
All reactions