Gurux Java client: safe Association LN retry loop
-
A retry must create a new evidence boundary. Reusing a half-open connection can hide whether the counter, challenge, or transport failed.
public final class AssociationRetry { public Result execute(ClientFactory factory, int maxAttempts) throws Exception { Exception last = null; for (int attempt = 1; attempt <= maxAttempts; attempt++) { try (DlmsClient client = factory.open()) { client.associate(); return client.read("0.0.40.0.0.255", 2); } catch (TemporaryTransportException ex) { last = ex; } } throw last; } }Synthetic stack excerpt:
com.example.dlms.TemporaryTransportException: UA not received before 3000 ms at com.example.dlms.HdlcLink.awaitUa(HdlcLink.java:184) at com.example.dlms.DlmsClient.associate(DlmsClient.java:91) at com.example.dlms.AssociationRetry.execute(AssociationRetry.java:7) Caused by: java.net.SocketTimeoutException: synthetic timeout -
Only retry transport-class failures. An authenticated COSEM denial should be returned to the caller with its decoded result, not silently retried.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login