-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Attempting to start a server when featurehub is down prevents server startup, instead it will hang in the EdgeFeatureHubConfig.init() method forever as it retries over and over.
My setup, spring boot 3 rest server using featurehub client side key. I tried both:
java-client-sse 1.4
java-client-jersey3 1.5
They have the same issue, however the java-client-jersey3 at least has some logs showing you where the issue is.
@Bean
public FeatureHubConfig featurehubConfig() {
log.debug("FeatureHubConfig: Creating");
FeatureHubConfig config = null;
try {
config = new EdgeFeatureHubConfig(provideLocalStackHost, apiClientSideEvalKey);
config.init(); // It gets stuck on this line and never proceeds
}
catch (Exception ex) {
log.error("FeatureHubConfig error: ", ex);
}
return config;
}This is the area that it gets stuck in the java-client-core:3.3 lib, EdgeFeatureHubConfig.java:78
@Override
public void init() {
try {
final Future<ClientContext> futureContext = newContext().build();
futureContext.get();
} catch (Exception e) {
log.error("Failed to initialize FeatureHub client", e);
}
}Note: I never see the log 'Failed to initialize FeatureHub client'
For the jersey client I'll see a lot of onMakeEventSourceException info logs of:
[featurehub-sdk] failed to connect to https://myfeaturehubhostisdown
The loop stack:
FutureTask.run()
EdgeRetryer.edgeResult
} else if (state == EdgeConnectionState.SERVER_CONNECT_TIMEOUT) {
executorService.submit(() -> {
backoff(serverConnectTimeoutMs, true);
reConnector.reconnect(); // <--
});
}Which calls:
JerseySSEClient.reconnect
JerseySSEClient.poll
this.retryer.getExecutorService().submit(this::initEventSource);With the end result of initEventSource being called periodically over and over again, while never returning from the initial EdgeFeatureHubConfig.init() call.
I suppose best case scenario, it returns from the init, but keeps attempting to connect periodically in the background while logging failures. However even if it threw an exception and failed out that would be preferable.