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 socketclient #14

Closed
krunalbhavsar opened this issue Jan 22, 2018 · 6 comments
Closed

unsubscribe socketclient #14

krunalbhavsar opened this issue Jan 22, 2018 · 6 comments
Labels

Comments

@krunalbhavsar
Copy link

socketClient?.unsubscribe(destination: "destination string is same as subscribe destination string")

Unsubscription of destination gives following error:

"org.apache.activemq.transport.stomp.ProtocolException: No subscription matched.\r\tat org.apache.activemq.transport.stomp.ProtocolConverter.onStompUnsubscribe(ProtocolConverter.java:734)\r\tat org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java:262)\r\tat org.apache.activemq.transport.ws.AbstractStompSocket.processStompFrame(AbstractStompSocket.java:151)\r\tat org.apache.activemq.transport.ws.jetty9.StompSocket.onWebSocketText(StompSocket.java:96)\r\tat org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextMessage(JettyListenerEventDriver.java:128)\r\tat org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)\r\tat org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:64)\r\tat org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextFrame(JettyListenerEventDriver.java:122)\r\tat org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:160)\r\tat org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:309)\r\tat org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:214)\r\tat org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:220)\r\tat org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:258)\r\tat org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:628)\r\tat org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:476)\r\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\r\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\r\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\r\tat java.lang.Thread.run(Unknown Source)\r")

@WrathChaos
Copy link
Owner

Hello @krunalbhavsar,
This is not an issue about StompClientLib. As you can see, it says the error: No subscription matched. Please check your topic names :)
Have fun!

@krunalbhavsar
Copy link
Author

krunalbhavsar commented Jan 27, 2018

Yes, It's an issue with subscription name but It doesn't accept the same string string I used to subscribe specific channel.

For example:

// destination
let destinationChannelTopic = "/topic/channel_1234"

// subscribe successful
socketClient?.subscribe(destination: destinationChannelTopic)

// unsubscribe not successful with same destination
socketClient?.unsubscribe(destination: destinationChannelTopic)

Here unsubcribe responds me an error: No subscription matched
Can you please help me to understand, what is wrong? What am I doing wrong?

As I analyzed from Subscribe and receive messages, subscription (a subscribe method) returns a string (subscription channel id) from server, that we need to store somewhere at client side (in our project/code) and we need to use the same string to unsubscribe.

This is not an iOS (swift) code but a sample that available in above link and we implemented in web application:

// subscribe
var subscription = client.subscribe("/queue/test", callback);

The subscribe() methods returns a JavaScript obect with 1 attribute, id, that correspond to the client subscription ID and one method unsubscribe() that can be used later on to unsubscribe the client from this destination.

// unsubscribe
subscription.unsubscribe();

So, is this only the method/possible way, for subscription and unsubscription. If yes, then we do not have any value returning to subscribe(...) that I can use to unsubscribe.

Can you please provide a sample code block, guiding me, how can I successfully unsubscribe from destination topic. I've almost implemented this library 'StompClientLib' in my project and everything works fine except 'unsubcribe'.

As an alternate solution to this issue, I disconnect client from server and reconnect again + subscribe all other destinations again. And this is not a proper way to handle but I have only this solution at this time.

Thanks you for your response. Please help to find out solution for this problem.

Krunal

@WrathChaos
Copy link
Owner

@krunalbhavsar Hello again,
Have you checked that can you subscribe correctly? If you cannot subscribe, you cannot unsubscribe either. If you need an example, please check the Example on the github. Example

@krunalbhavsar
Copy link
Author

With this code, I can subscribe correctly.

// destination
let destinationChannelTopic = "/topic/channel_1234"

// subscribe successful
socketClient?.subscribe(destination: destinationChannelTopic)

But when I try to unsubscribe, using the same destination string, it replies with an error.

// unsubscribe not successful with same destination
socketClient?.unsubscribe(destination: destinationChannelTopic)

:(
Don't know, what's wrong here.... in this code. Everything according to sample code.

@krunalbhavsar
Copy link
Author

Here I found a proper (working) solution: https://stackoverflow.com/questions/48472473/stompclientlib-unsubscribe-socketclient/48769453#48769453

let destination = "/topic/channel_1234"
let ack = destination 
let subsId = destination
let header = ["destination": destination, "ack": ack, "id": subsId]

// subscribe
socketClient?.subscribeWithHeader(destination: destination, withHeader: header)

// unsubscribe
socketClient?.unsubscribe(destination: subsId)

@WrathChaos
Copy link
Owner

@krunalbhavsar I'm glad to find the working solution. I will add it to the ReadME part.
Thank you so much :)

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

No branches or pull requests

2 participants