finos / symphony-bdk-java

The Symphony BDK (Bot Developer Kit) for Java helps you to create production-grade Chat Bots and Extension Applications on top of the Symphony REST APIs.
https://symphony-bdk-java.finos.org
Apache License 2.0
23 stars 69 forks source link

Datafeed stops on unhandled socketimeoutexception #82

Closed PhilippeVialatte-Symphony closed 4 years ago

PhilippeVialatte-Symphony commented 4 years ago

An unhandled socketimeoutexception causes the process of trying to connect to Datafeed from time to time to stop. After that, the application needs to be restarted to get back to work. The exception trail is the following:

1- (DatafeedClient.java:45) builder.post(null) call throws SocketTimeoutException; 2- (DatafeedEventsService.java:228) SocketTimeoutException not unhandled by catch (SymClientException e1); 3- (DatafeedEventsService.java:173) SocketTimeoutException still unhandled, as it happens inside CompletableFuture.exceptionally() it will be wrapped in an ExecutionException 4- (DatafeedEventsService.java:185) catch ExecutionException and log it 5- bot stops to read Datafeed.

Fix suggestion: Catch SocketTimeoutException on DatafeedClient.createDatafeed() and handle the same way as unsuccessful response (DatafeedClient.java:46).

ystxn commented 4 years ago

that shouldn't be the case. since 1.0.38, the config.json field connectionTimeout was added to allow granular control over when a SocketTimeoutException would be thrown. this defaults to 35000 to cater for the unique nature of read datafeed pausing for 30s before returning a 204 if no events occur.

this is a simple test i did by specifying connectionTimeout as 6000 and datafeedEventsErrorTimeout as 2 (to reduce the retry delay). the exception is handled and the bot re-creates a new datafeed and goes on to read it.

clients.SymBotClient                     : Authenticated as sample-bot (349026222349157)
services.DatafeedEventsService           : Using previous datafeed id: e297b36e-ba4a-4998-a123-5a1a31e24a9b
com.symphony.ps.sample.SampleBot         : Started SampleBot in 3.043 seconds (JVM running for 3.6)
services.DatafeedEventsService           : Connection timed out after 6 seconds
services.DatafeedEventsService           : Sleeping for 2 seconds before retrying..
clients.symphony.api.DatafeedClient      : Creating new datafeed for bot sample-bot..
clients.symphony.api.DatafeedClient      : Created new datafeed 2a9f92bc-9efe-476c-aa8f-b8a7f9e957ab for bot sample-bot
services.DatafeedEventsService           : Connection timed out after 6 seconds
services.DatafeedEventsService           : Sleeping for 2 seconds before retrying..
clients.symphony.api.DatafeedClient      : Creating new datafeed for bot sample-bot..
clients.symphony.api.DatafeedClient      : Created new datafeed 18769dd4-b378-499e-8bc6-92ff5602e142 for bot sample-bot
services.DatafeedEventsService           : Connection timed out after 6 seconds
services.DatafeedEventsService           : Sleeping for 2 seconds before retrying..
clients.symphony.api.DatafeedClient      : Creating new datafeed for bot sample-bot..
clients.symphony.api.DatafeedClient      : Created new datafeed e089d55c-60cf-47b2-bc33-2b89593c9320 for bot sample-bot
services.DatafeedEventsService           : Connection timed out after 6 seconds
services.DatafeedEventsService           : Sleeping for 2 seconds before retrying..
clients.symphony.api.DatafeedClient      : Creating new datafeed for bot sample-bot..
clients.symphony.api.DatafeedClient      : Created new datafeed acdebdb9-6a40-4bf8-9f42-552a578c7170 for bot sample-bot
services.DatafeedEventsService           : Connection timed out after 6 seconds
services.DatafeedEventsService           : Sleeping for 2 seconds before retrying..
clients.symphony.api.DatafeedClient      : Creating new datafeed for bot sample-bot..
clients.symphony.api.DatafeedClient      : Created new datafeed 4fd004bc-dd55-4338-bace-26130e7648b9 for bot sample-bot
thibauult commented 4 years ago

Fixed by : https://github.com/SymphonyPlatformSolutions/symphony-api-client-java/pull/88