StompProtocolAndroid icon indicating copy to clipboard operation
StompProtocolAndroid copied to clipboard

How to get session id?

Open hoi-nx opened this issue 6 years ago • 6 comments

How to get session id from client when connect websocket successful?

hoi-nx avatar Feb 15 '19 10:02 hoi-nx

mStompClient.lifecycle().subscribe(lifecycleEvent -> { switch (lifecycleEvent.getType()) {

    case OPENED:
        sessionID = // how do I get this?
        Log.d(TAG, "Stomp connection opened");
        break;
        
    case ERROR:
        Log.e(TAG, "Error", lifecycleEvent.getException());
        break;
        
    case CLOSED:
         Log.d(TAG, "Stomp connection closed");
         break;
}

});

hoi-nx avatar Feb 15 '19 10:02 hoi-nx

What is sessionID supposed to be?

forresthopkinsa avatar Feb 15 '19 17:02 forresthopkinsa

i want to session id like that https://stackoverflow.com/questions/28009764/how-to-get-session-id-on-the-client-side-websocket

hoi-nx avatar Feb 16 '19 07:02 hoi-nx

That's SockJS. This library is not SockJS.

forresthopkinsa avatar Feb 16 '19 07:02 forresthopkinsa

Stomp specification 1.2 does specify "session" on connected frame. But this is not "must" implemented feature, but is "may" add it. So if the stomp server you use sets session (which is optional), it will be available on header of connected frame with "session" as key.

Link to Stomp1.2 specs

subash-bhandari avatar Mar 13 '19 16:03 subash-bhandari

Use this library its working fine, replace server url and port with your custom server url and your port. https://github.com/SayyedUmar/Stomp-Android-Client

testGumar avatar May 01 '19 07:05 testGumar