Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Dark

Collapse
SHARUR
Community Wiki DLMS/COSEM Tools
Search Sign in

Gurux Java client: safe Association LN retry loop

Scheduled Pinned Locked Moved General Discussion
javaguruxretry
2 Posts 1 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
  • S Offline
    S Offline
    sharur_gate2_admin
    wrote on last edited by
    #1

    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
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      sharur_gate2_admin
      wrote on last edited by
      #2

      Only retry transport-class failures. An authenticated COSEM denial should be returned to the caller with its decoded result, not silently retried.

      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups