forresthopkinsa / StompProtocolAndroid

Websockets on Android
MIT License
11 stars 4 forks source link

subscribe not working on topic #10

Open LovepreetSinghLotey opened 5 years ago

LovepreetSinghLotey commented 5 years ago

StompClient client = Stomp.over(Stomp.ConnectionProvider.OKHTTP, "ws://192.168.1.75:9464/chatServer"); client.connect();

    client.topic("topic.58.rooms")
            .subscribe ( stompMessage -> {
                System.out.println("-----------------------------");

            });

message from server is receiving and showing in logcat but is not receiving in the subscribe block

forresthopkinsa commented 5 years ago

I'm not completely understanding your issue. You say you can see that you're receiving the message in Logcat -- what are you seeing, exactly? I need a lot more details.

However, I highly recommend that you use Scarlet for any new projects. The StompProtocolAndroid libs are outdated.

LovepreetSinghLotey commented 5 years ago

scarlet has no documentation for STOMP, and by what i said is, the response from server is coming to the okHttpConnectionProvider's (text receive block), but is not getting emitted to my subscribe block.

forresthopkinsa commented 5 years ago

Still not enough detail. Show me logs and code.

NeerajThapliyal commented 4 years ago

i have written code like this StompClient client = Stomp.over(Stomp.ConnectionProvider.JWS, "ws://192.168.225.133:9191/ws");

    client.connect();
    client.topic("/topic/greetings").subscribe(message -> {
        Log.i("topic", "Received message: " + message.getPayload());
    },error->Log.e("topic","===>error during subscribe topic"));

    client.send("/app/hello", "world").subscribe(
            () -> Log.d("sendm", "Sent data!"),
            error -> Log.e("sendm", "Encountered error while sending data!", error)
    );

but could getting topic subscribe logs. here is my logs D/WebSocketsConnectionProvider: onWebsocketHandshakeReceivedAsClient with response: 101 Switching Protocols D/WebSocketsConnectionProvider: onOpen with handshakeData: 101 Switching Protocols D/AbstractConnectionProvider: Emit lifecycle event: OPENED D/AbstractConnectionProvider: Send STOMP message: CONNECT version:1.1,1.0 heart-beat:0,0

��

D/socket: Stomp connection opened

forresthopkinsa commented 4 years ago

Looks like you're successfully connected, are you sure the server is sending anything to that topic?

NeerajThapliyal commented 4 years ago

@forresthopkinsa server sending data in topic . i have solved that issue by enable cleartext support in android https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted/50834600#50834600

violettomsk commented 4 years ago

What happens when I subscribe too fast while websocket is connecting?

forresthopkinsa commented 4 years ago

@violettomsk I'd expect it to subscribe to the topic once the connection completes. Is that the behavior you observe?