Not able to subscribe websocket using java code , getting errror

While I am running my java code to connect to websocket, I am getting below error message:

connect:socket.fyers.in/hsm/v1-5/prod

OnMessage: {“code”:200,“type”:“cn”,“message”:“Authentication done”}

On open: HSM Connected

OnMessage: {“code”:200,“type”:“full”,“message”:“Full Mode On”}

log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

On Error: {“code”:-15,“s”:“error”,“type”:“sf”,“message”:“Could not subscribe : Please provide valid token”}

========================

I am using below java code, Pls check the code and suggest what is missing here:

public static void main(String[] args) {
    String clientID = "ABCDEF...-100";
    String liveToken = "eyJ....";

    FyersClass fyersClass = FyersClass.getInstance();
    fyersClass.clientId = clientID;
    fyersClass.accessToken = liveToken;

    Step_3 step3 = new Step_3();
    step3.WebSocket();
}
public void WebSocket() {

    List scripList = new ArrayList<>();
    scripList.add("NSE:SBIN-EQ");  // test first

    FyersSocket fyersSocket = new FyersSocket(3);
    fyersSocket.webSocketDelegate = this;

    fyersSocket.ConnectHSM(ChannelModes.FULL);

    fyersSocket.SubscribeData(scripList);
}

Hey @aRlyMzL38n,

As per the error message, it appears that an invalid token is being passed. Please try again with new token. If the issue still persists, kindly DM your client ID, we will connect and check.

Hi Naresh,

I tried with new token. Still I am getting same error message.

connect:socket.fyers.in/hsm/v1-5/prod

OnMessage: {“code”:200,“type”:“cn”,“message”:“Authentication done”}

On open: HSM Connected

OnMessage: {“code”:200,“type”:“full”,“message”:“Full Mode On”}

log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

On Error: {“code”:-15,“s”:“error”,“type”:“sf”,“message”:“Could not subscribe : Please provide valid token”}





My client Id is XH02492.

Pls let me know when we can connect.

Hey Hemanth, following our phone conversation, your concern has been addressed. Please use valid access token.