Reasons for getting disconnected frequently from websocket

Shreyas
I am getting frequently(after every 15-20 min) disconnected from the WebSocket.
I have subscribed for around 150 token for websocket.
Is it the problem on your side or my side?
Tagged:
  • sujith
    Hi @Shreyas,
    Can you print exception stacktrace and check?
  • Shreyas
    @sujith
    No Exception is raised! The callback method


    tickerProvider.setOnDisconnectedListener(new OnDisconnect() {
    @Override
    public void onDisconnected() {
    // your code goes here
    System.out.println("i got disconnected"+ Calendar.getInstance());
    }
    });


    gets called and I stop receiving data.
  • sujith
    Yes, you can do exponential backoff for reconnection in onDisconnect callback.
  • Shreyas
    Thanks @sujith ,
    But I did not get you. Could you explain in simpler terms ?
  • sujith
    sujith edited December 2016
    Hi @Shreyas,
    You try reconnecting to ticker server once in onDisconnect calback, if fails try after 5 seconds, if fails you try after 5*2 seconds and third time 5*3.
    Basically 5*n time interval for every n th retry.
  • Shreyas
    Thanks @sujith. It solved my problem :)
This discussion has been closed.