Why am I not recieving order Updates from Web Socket connection

stalwalk
I am setting up websocket like the below. But i dont recieve Order Updates. What could be missing?

//This is a class OrderUpdateListenerService implements OnOrderUpdate
@Override
public void onOrderUpdate(Order order) {
int pendingQuantity = Integer.parseInt(order.pendingQuantity);
boolean partialFill = pendingQuantity > 0;
if (partialFill) {
handlePartialFill(order);
}
if (order.status.equals(ORDER_STATUS_COMPLETE)) {
handleOrderCompletion(order);
}
}



My code does not receive order updates. I start the connection once the request token is recieved.
Here is the startup logic:

public User generateZerodhaSession(String requestToken) {
User user = null;
try {
user = createZerodhaClientAndStoreSecrets(requestToken);
setUpWebSocketConnection(user);
} catch (Throwable t) {
mainExceptionHandler.handleNonInteractiveException("Failed to generate Zerodha session at login.", t);
}
return user;
}

private void setUpWebSocketConnection(User user) throws KiteException {
ticker = new KiteTicker(user.accessToken, user.apiKey);
ticker.setOnOrderUpdateListener(orderUpdateSvc);
// Make sure this is called before calling connect.
ticker.setTryReconnection(true);
//maximum retries and should be greater than 0
ticker.setMaximumRetries(10);
//set maximum retry interval in seconds
ticker.setMaximumRetryInterval(30);

/** connects to com.zerodhatech.com.zerodhatech.ticker server for getting live quotes*/
ticker.connect();

/** You can check, if websocket connection is open or not using the following method.*/
boolean isConnected = ticker.isConnectionOpen();
log.info("Kite WEb socket is connect: {}", isConnected);
}
  • stalwalk
    Oops My bad.. :'(
    My code calls setup websocket only on login. However, when i Restart the app, i dont do a login. Login is needed only once a day. I need to ensure that the setup Web socket is called on every restart irrespective of the login.
Sign In or Register to comment.