Hi,
I have created a NotificationHandler instance to listen to events from a topic. Normall for the first 24 hours everything works fine but communication channel gives "Client Not found" after 24 hours. Here is the error response json.
=====================================================
status: 400
body: {"error":"invalid_client","description":"client not found","error_description":"client not found"}
I understand that the channel is active only for 24 hours. But how do add logic into my code such that it remains active forever and i don't get any such errors. We are using Spring Configuration to authorize the api client and connect the NotificationHandler. Here is the sample code:
Setting up ApiClient
@Bean
public ConversationsApi conversationsApi(ApiClient apiClient, NotificationHandler notificationHandler) {
return new ConversationsApi(apiClient);
}
@Bean
public NotificationHandler notificationHandler(ApiClient apiClient, ChatNotificationListener chatNotificationListener) throws WebSocketException, IOException, ApiException {
try {
NotificationHandler handler = NotificationHandler.Builder.standard().withApiClient(apiClient).withNotificationListener(chatNotificationListener)
.withAutoConnect(true).build();
handler.connect(true);
return handler;
} catch (ApiException | WebSocketException | IOException e) {
log.error("Exception when calling postNotificationsChannels", e);
throw e;
}
}
@Bean
public ApiClient apiClient(@Value("${genesys.auth.client.id}") String clientId, @Value("${genesys.auth.client.secret}") String clientSecret) throws IOException, ApiException {
var apiClient = ApiClient.Builder.standard().withBasePath(PureCloudRegionHosts.ap_southeast_2)
.withLoggingConfiguration(buildLoggingConfiguration())
.withRetryConfiguration(buildRetryConfiguration()).build();
apiClient.authorizeClientCredentials(clientId, clientSecret);
apiClient.setShouldRefreshAccessToken(true);
com.mypurecloud.sdk.v2.Configuration.setDefaultApiClient(apiClient);
return apiClient;
}
private ApiClient.RetryConfiguration buildRetryConfiguration() {
return new ApiClient.RetryConfiguration();
}
private ApiClient.LoggingConfiguration buildLoggingConfiguration() {
var loggingConfiguration = new ApiClient.LoggingConfiguration();
loggingConfiguration.setLogLevel("debug");
loggingConfiguration.setLogRequestBody(true);
loggingConfiguration.setLogResponseBody(true);
return loggingConfiguration;
}
=======================================================