Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsubscribe channel not working in socketcluster #24

Open
niraj1991 opened this issue Feb 20, 2019 · 7 comments
Open

unsubscribe channel not working in socketcluster #24

niraj1991 opened this issue Feb 20, 2019 · 7 comments

Comments

@niraj1991
Copy link

niraj1991 commented Feb 20, 2019

Hi,
@sacOO7

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

@jrvaja
Copy link

jrvaja commented Mar 4, 2019

@sacOO7 @niraj1991
Just reviewed it, it does work with web version but not with iOS.

I request to @sacOO7 to have a look into this and provide a guideline to make it work.

Thanks,

@sacOO7
Copy link
Owner

sacOO7 commented Mar 5, 2019

Hi @niraj1991 @jrvaja , will look into it. Also it will be helpful if you can put your code here @jrvaja

@jrvaja
Copy link

jrvaja commented Mar 5, 2019

@sacOO7

Thanks for writing to me.

We are using the same code as you mentioned in the demo for iOS.
Github link: https://github.com/sacOO7/socketcluster-client-swift

//with acknowledgement
    client.unsubscribeAck(channelName: "yell", 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)
        }
    })

The above method throws an error for invalid channel name, that's @niraj1991 has already mentioned in his post.

For Web
Below is code that I am using for Web Application with VueJS which is working fine.

import socket from "./socketCluster";
Vue.prototype.$socket = socket;

subscribeChannel(channelName, watcher, clearWatcher = false) {
    const channel = this.$socket.subscribe(channelName);
    if (clearWatcher) channel.unwatch();

    channel.watch(data => {
        watcher(data);
    });
}
unsubscribeChannel(channelName) {
    this.$socket.unsubscribe(channelName);
}

JavaScript Package: "socketcluster-client": "^14.2.1"

Let me know if you need any other details, I would be happy to share you.

Regards,

@KetaniPhone
Copy link

Hello @sacOO7, @niraj1991 and @jrvaja

I have also faced the same issue.
Please let me know if anyone will find the solution to that issue.
I am also trying to above code which mentioned here by @niraj1991

Thanks,

@gauravrami
Copy link

Hello @sacOO7

I am also facing this issue, I am not able to unsubscribe the channel. Please, @sacOO7 please help me to fix this issue.

Hi, @niraj1991 & @KetaniPhone, if you got any solution then please can you post the answer for this issue.

Thanks in advance.

Regards,
Gaurav

@sachinsh76
Copy link

Hello, @niraj1991 @jrvaja @KetaniPhone @gauravrami I will look into it. We have updated SC server library, we are updating all clients in accordance with it.

@AddoniOS
Copy link

Hello @niraj1991 @jrvaja @KetaniPhone @gauravrami @sacOO7, i have faced same issue in iOS. if you got any solution then please can you post the answer for this issue.

Thanks everybody

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants