title: How to remove durable subscription using stompit
body: <p>We are using ActiveMQ 5.16.1 with the <a href="https://github.com/gdaws/stompit" rel="nofollow noreferrer">stompit</a> client to create a durable subscription in our NodeJS app using the following code snippet:</p>
  <pre><code>  var connectOptions = {
      &quot;host&quot;: &quot;&quot;,
      &quot;port&quot;: amqPort,
      rejectUnauthorized: false,
      checkServerIdentity: () =&gt; { },
      &quot;connectHeaders&quot;: {
          &quot;heart-beat&quot;: &quot;15000,15000&quot;,// hear-beat of 15 seconds
          'login': 'admin',
           'passcode': 'admin',
           'client-id' : &quot;agent-manager&quot;
      }
    };
  
    var server1 =  connectOptions;
    server1.host = amqPrimaryHost;
    var server2 = connectOptions;
    server2.host = amqSecondaryHost;
     
     var amqSubscription;
       var subscribeHeaders = {
              &quot;destination&quot;: &quot;/topic/delivery-reports&quot;,          
              &quot;activemq.subscriptionName&quot;: &quot;channel_manager_delivery_reports&quot;,
              &quot;ack&quot;: &quot;client-individual&quot;                          
      };
      var connectionManager = new stompit.ConnectFailover([server1,server2], reconnectOptions);
         connectionManager.connect(function (error, client, reconnect){
          if (error) {
              logger.error(&quot;Terminal error, gave up reconnecting &quot;, error);
              return;
          }
          client.on(&quot;error&quot;, function (error) {
              if(!client)
                reconnect();
          });
      
     
          amqSubscription=client.subscribe(subscribeHeaders, function (error, message,subscription) {
              logger.info(&quot;going to subscribe&quot;)
              if (error) {
                  logger.error(&quot;Subscription failed. Going to disconnect&quot;, error);
                  subscription.unsubscribe();
                 // reconnect();
              
              }
              logger.info(&quot;subscribed&quot;)  
          });
      
      });
  
     function unsubscribe () {
          
          logger.info(&quot;Going to unsub&quot;)
          amqSubscription.unsubscribe({&quot;activemq.subscriptionName&quot;:&quot;channel_manager_delivery_reports&quot;})
  
     };
  </code></pre>
  <p>However, when I call the <code>unsubscribe</code>, it only changes the <code>Subscriber</code> active status to false but does not remove it from the active subscribers' list as shown in the screenshot.<a href="https://i.stack.imgur.com/5V9pH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5V9pH.png" alt="enter image description here" /></a></p>
  <p>Getting the following exception in stomp.logs.</p>
  <pre><code>2021-05-12 05:20:14,826 [0.1:50251@61613] WARN  ProtocolConverter              - Exception occurred for client agent-manager (tcp://127.0.0.1:50251) processing: UNSUBSCRIBE -&gt; javax.jms.JMSException: Durable consumer is in use
  2021-05-12 05:20:14,826 [0.1:50251@61613] DEBUG ProtocolConverter              - Exception detail
  javax.jms.JMSException: Durable consumer is in use
      at org.apache.activemq.broker.region.TopicRegion.removeSubscription(TopicRegion.java:220)
      at org.apache.activemq.broker.region.RegionBroker.removeSubscription(RegionBroker.java:457)
      at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:119)
      at org.apache.activemq.advisory.AdvisoryBroker.removeSubscription(AdvisoryBroker.java:396)
      at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:119)
      at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:119)
      at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:119)
      at org.apache.activemq.broker.TransportConnection.processRemoveSubscription(TransportConnection.java:419)
      at org.apache.activemq.command.RemoveSubscriptionInfo.visit(RemoveSubscriptionInfo.java:81)
      at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:331)
      at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:200)
      at org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:45)
      at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:301)
      at org.apache.activemq.transport.stomp.StompTransportFilter.sendToActiveMQ(StompTransportFilter.java:97)
      at org.apache.activemq.transport.stomp.ProtocolConverter.sendToActiveMQ(ProtocolConverter.java:179)
      at org.apache.activemq.transport.stomp.ProtocolConverter.onStompUnsubscribe(ProtocolConverter.java:714)
      at org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java:251)
      at org.apache.activemq.transport.stomp.StompTransportFilter.onCommand(StompTransportFilter.java:85)
      at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
      at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233)
      at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)
      at java.lang.Thread.run(Thread.java:748)
  2021-05-12 05:20:14,827 [0.1:50251@61613] TRACE ProtocolConverter              - Command that caused the error: UNSUBSCRIBE
  activemq.subscriptionName:channel_manager_delivery_reports
  receipt:1
  id:1
  </code></pre>
  <p>Any suggestion on how to remove the durable subscription properly via stompit.</p>