StompProtocolAndroid icon indicating copy to clipboard operation
StompProtocolAndroid copied to clipboard

Can't send multiple STOMP messages

Open dimonik opened this issue 8 years ago • 3 comments

If I do this

mStompClient = Stomp.over(WebSocket.class, endpoint);
mStompClient.connect();

and immediately following with

switch (lifecycleEvent.getType())
{
    case OPENED:
        mStompClient.send(stomp_p2p_channel, msg_body);

then message is sent successfully.

If i do sending one more time (after 5 sec)

mStompClient.send(stomp_p2p_channel, msg_body);

the message is NOT sent, despite connection is still alive.

Bug?

dimonik avatar Jan 20 '17 14:01 dimonik

Try mStompClient.send(stomp_p2p_channel, msg_body).subscribe();

KyleADOlson avatar Jan 22 '17 08:01 KyleADOlson

Thank you, this work!

But, could you explain why client need to subscribe for each sent message?

dimonik avatar Jan 25 '17 11:01 dimonik

send returns an Observable, which means it shouldn't do anything unless subscribed to. If you don't know what an Observable is, read this.

forresthopkinsa avatar Sep 29 '17 23:09 forresthopkinsa