1

I'm facing the error message 'There is no current subscription with tag 'T_1'. Due to this error, my connections are terminated which decreases the performance of my system. First of, the environment I'm running:

  1. Client app (Created in c#)
  2. Server app (Created with spring boot version 2.6.0)
  3. RabbitMQ (3.9.11) as message broker. Using STOMP plugin.

These 3 services works great in general. I'm not having any issues with these besides the error message described above (There is no current subscription with tag 'T_1'). Please also note that the tag can be any subscription ID, not neccesairy T_1, but also e.g T_100

When does the error occur: I've noticed that the error usually occurs during a particular state of my program. In this state, the C# client app should subscribe to a topic named 'xxx.pong'. Empty messages are frequently sent to this topic by other client applications. Once retrieved a pong message, the C# client app should unsubscribe to this topic.

How I replicated the issue: I created a test case similar to the description above. I've added the code as an attachment. The error occurs around 1 out of 10 test runs and it's the consumer (which subscribes and unsubscribes) that retrieves the error message. The publisher (which frequently sends pong messages) does not retrieve errors.

Logs when the error occurs:

Spring boot log:

2022-01-06 14:04:12.165 ERROR 25116 --- [ent-scheduler-7] o.s.m.s.s.StompBrokerRelayMessageHandler : Received ERROR {message=[Subscription not found], content-type=[text/plain], version=[1.0,1.1,1.2], content-length=[48]} session=0009197b-1281-0fdb-08fe-3f5de331fdb9, user=XXX) text/plain payload=There is no current subscription with tag 'T_1'.

RabbitMQ log (Note that the RabbitMQ serves timezone is 1 hour behind my local PC zone):

2022-01-06 13:04:06.450156+00:00 [info] <0.9710.0> Supervisor {<0.9710.0>,rabbit_connection_helper_sup}: child heartbeat_sender started (<0.9728.0>): {rabbit_heartbeat,start_heartbeat_sender,[#Port<0.1398>,10,#Fun<rabbit_stomp_reader.1.31184097>,{heartbeat_sender,unknown}]}
2022-01-06 13:04:06.450237+00:00 [info] <0.9710.0> Supervisor {<0.9710.0>,rabbit_connection_helper_sup}: child heartbeat_receiver started (<0.9729.0>): {rabbit_heartbeat,start_heartbeat_receiver,[#Port<0.1398>,55,#Fun<rabbit_stomp_reader.2.31184097>,{heartbeat_receiver,unknown}]}
2022-01-06 13:04:11.359597+00:00 [info] <0.9733.0> Supervisor {<0.9733.0>,rabbit_amqqueue_sup}: child rabbit_amqqueue started (<0.9734.0>): {rabbit_prequeue,start_link,[{amqqueue,{resource,<<"/">>,queue,<<"stomp-subscription-gItDy9sxnW3_TUCGLOs8PQ">>},false,true,none,[],none,[],[],[],undefined,undefined,[],[],live,0,[],<<"/">>,#{user => <<"guest">>},rabbit_classic_queue,#{}},declare,<0.9732.0>]}
2022-01-06 13:04:11.403234+00:00 [dbug] <0.9734.0> Deleting auto-delete queue 'stomp-subscription-gItDy9sxnW3_TUCGLOs8PQ' in vhost '/' because its last consumer with tag 'T_1' was cancelled
2022-01-06 13:04:11.412333+00:00 [info] <0.9687.0> closing STOMP connection <0.9687.0> (172.17.0.1:57136 -> 172.17.0.2:61613)
2022-01-06 13:04:11.412428+00:00 [dbug] <0.9741.0> Closing all channels from connection '172.17.0.1:57136 -> 172.17.0.2:61613' because it has been closed

This is the test which sometimes invokes the error:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyProject.Rabbitmq
{
    [TestClass]
    public class RabbitMqTests
    {
        private int _pongCounter;
        private int _pingCounter;
        private bool shouldStop = false;

        [TestMethod]
        public void TestTags()
        {
            var internalWs = new InternalWebsocket("Consumer");
            internalWs.Open();

            Thread.Sleep(10000);

            List<StompSubscription> subscriptions = new List<StompSubscription>();

            var task = new Task(() => SpamPong(), TaskCreationOptions.LongRunning);
            task.Start();

            Thread.Sleep(10000);

            var sub = internalWs.Subscribe(
                "xxx.pong",
                OnPongMessage, true);

            while (_pongCounter == 0)
            {
                Thread.Sleep(1);
            }

            internalWs.Unsubscribe(sub);

            Thread.Sleep(10000);
        }

        private void SpamPong()
        {
            var internalWs = new InternalWebsocket("producer");
            internalWs.Open();

            Thread.Sleep(10000);


            while (!shouldStop)
            {
                try
                {
                    internalWs.Send(new object(), "xxx.pong");
                }
                catch (Exception e)
                {
                    Logger.Log.Info("Has failed to send message");
                }

                Thread.Sleep(30);
            }
        }


        public virtual void OnPongMessage(object sender, InternalMessageEventArgs args)
        {
            Interlocked.Increment(ref _pongCounter);
        }

        public virtual void OnPingMessage(object sender, InternalMessageEventArgs args)
        {
            Interlocked.Increment(ref _pingCounter);
        }
    }
Chillychillx
  • 23
  • 1
  • 5

0 Answers0