I’m using MarketDataStreamerV3 (Java SDK) to stream Mode.FULL option feeds (I need option Greeks/delta). The streamer connects successfully and I can subscribe & receive live updates if I call subscribe(...) from one code path (e.g., after my evaluateAndPlace()), but when I call the same subscribe(...) from another method (e.g., findStrikePrices() where I compute a list of instrument keys and call subscribeNew(key)), the socket connects then immediately disconnects with close code 1000 (normal closure). I don’t see an explicit error — just a close with code 1000 and reason blank.
What I expect
-
streamer.connect()→onOpen→streamer.subscribe(keys, Mode.FULL)→ continuousonMarketUpdatemessages withfullFeed.marketFF.optionGreeks.delta. -
No unexpected disconnects (or a clear error/ack if subscribe is rejected).
What I see
-
onOpenfires and logs show subscription attempt succeeded. -
I receive one
marketUpdatewith manyFeedentries (option data + Greeks). -
Immediately afterwards the WS
onCloseis invoked withstatusCode=1000and empty reason. -
This behavior depends on where I call
subscribeNew(key)from: one caller works fine; another causes the disconnect.
Minimal relevant logs
INFO UpstoxMarketAdapterImpl ensureStreamerStarted [UPSTOX] Connecting streamer…
INFO DeltaTradingService init DeltaTradingService initialized - waiting for Nifty open price…
INFO UpstoxMarketAdapterImpl lambda$0 [UPSTOX-WS] Connected
INFO UpstoxMarketAdapterImpl lambda$0 [UPSTOX] subscribing pending keys (FULL): [NSE_INDEX:NIFTY_50]
INFO UpstoxMarketAdapterImpl lambda$0 [UPSTOX] subscribed pending keys: [NSE_INDEX:NIFTY_50]
INFO OptionChainService lambda$7 Update: MarketUpdateV3{ type=null, feeds={NSE_FO|53023=Feed{ fullFeed=FullFeed{ marketFF={ ltpc={ltp=75.8}, optionGreeks={delta=0.3302, …} }}} … }, requestMode=full_d5 }
INFO OptionChainService lambda$9 statusCode :1000, reason:
Another run where I subscribe many FO keys at once:
INFO OptionChainService subscribeNew Keys: [NSE_FO|52851, NSE_FO|52855, …, NSE_FO|53027]
INFO OptionChainService lambda$7 Update: MarketUpdateV3{ type=null, feeds={NSE_FO|53023=Feed{ fullFeed=FullFeed{marketFF={optionGreeks=OptionGreeks{delta=0.3302,…}}}}, …}, requestMode=full_d5 }
INFO OptionChainService lambda$9 statusCode :1000, reason:
Relevant code excerpts (subscription / connect)
// create streamer
final ApiClient defaultClient = Configuration.getDefaultApiClient();
final OAuth oauth = (OAuth) defaultClient.getAuthentication(“OAUTH2”);
oauth.setAccessToken(tokenService.getAccessToken());
streamer = new MarketDataStreamerV3(defaultClient);
streamer.setOnOpenListener(() → {
log.info(“[UPSTOX-WS] Connected”);
if (!keys.isEmpty()) {
streamer.subscribe(keys, Mode.FULL);
log.info(“subscribed keys : {}”, keys);
}
});
streamer.setOnMarketUpdateListener(marketUpdate → {
log.info(“Update: {}”, marketUpdate);
// process feeds…
});
streamer.setOnCloseListener((statusCode, reason) → {
log.info(“statusCode :{}, reason:{}”, statusCode, reason);
disconnect();
});
streamer.connect();