1

Unsubscribe channel not working on socketcluster.

I have to subscribe 20 channel. Now I want unsubscribe 10 channel. So We are use below code for subscribe.

//  For subscribe 
SoketManager.client.subscribeAck(channelName:"random") { (str, obj1, obj2) in
        print ("Got data for channel", str)
 }

//  Listening to channel                 
SoketManager.client.onChannel(channelName:"random", ack: {
         (channelName : String , data : AnyObject?) in
      print ("Got data for channel", channelName, " object data is ", data ?? "")
 })

We are use below code for unsubscribe.

//  For unsubscribe 
 SoketManager.client.unsubscribeAck(channelName:"random", ack : {
       (channelName : String, error : AnyObject?, data : AnyObject?) in
          if (error is NSNull) {
                        print("Successfully unsubscribed to channel ", channelName)
           } else {
                        print("Got error while unsubscribing ", error ?? "")
          }
 })

When I am call "unsubscribeAck" method always get error. Here is error.

{
    message = "Failed to unsubscribe socket from the [object Object] channel - Socket YFaGYE5Tbu1_8we2AAAG tried to unsubscribe from an invalid channel name";
    name = BrokerError;
}

Also I am trying with socketcluster demo as well but It not working for me.

Github link: https://github.com/sacOO7/socketcluster-client-swift

Appreciate your help.

Thanks

Niraj
  • 89
  • 9
  • 1
    Are you sure you are unsubscribing from a channel that you were previously subscribed to? The pieces of code that you posted do not demonstrate the flow of your app. – pckill Feb 20 '19 at 09:44
  • 1
    Yes I am sure, Currently I am prepare a demo. So hardcoded the channel name "random". – Niraj Feb 20 '19 at 11:08

0 Answers0