Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Generic Exception Raised On HLS Authentication Failure Instead of GXDLMSException

Generic Exception raised on HLS authentication failure instead of GXDLMSException

By eriktrif , 26 August, 2026
Forums
Gurux DLMS for Python

GXDLMSClient.py:

Current code:
if not equals:
    raise Exception(
        "parseApplicationAssociationResponse failed. "
        + " Server to Client do not match."
    )

Should be:
# In GXDLMSClient.py imports:
from .GXDLMSException import GXDLMSException
from .enums import AssociationResult  # (add to existing 'from .enums import ...')

# In parseApplicationAssociationResponse():
if not equals:
    raise GXDLMSException(
        AssociationResult.PERMANENT_REJECTED,
        SourceDiagnostic.AUTHENTICATION_FAILURE,
    )

Reason:

When HLS authentication fails, parseApplicationAssociationResponse() raises a raw Python Exception instead of a typed GXDLMSException.

This causes several issues:

1. Dead code in GXDLMSReader.initializeConnection():
In GXDLMSReader.py, HLS authentication is wrapped in:
try:
    for it in self.client.getApplicationAssociationRequest():
        self.readDLMSPacket(it, reply)
    self.client.parseApplicationAssociationResponse(reply.data)
except GXDLMSException as ex:
    #Invalid password.
    raise GXDLMSException(AssociationResult.PERMANENT_REJECTED, SourceDiagnostic.AUTHENTICATION_FAILURE)

Because parseApplicationAssociationResponse() raises a base Exception (which does not inherit from GXDLMSException), the except GXDLMSException handler is never reached.

2. Inconsistency between LLS and HLS:
For Low-Level Security (LLS), authentication failure in parseAareResponse() raises GXDLMSException with:
AssociationResult.PERMANENT_REJECTED
SourceDiagnostic.AUTHENTICATION_FAILURE

HLS authentication failure should produce the same typed exception with the corresponding association error and diagnostic values.

3. Broken error handling for client applications:
Callers cannot inspect structured error attributes (result, diagnostic, errorCode) and are forced to catch generic Exception and parse the error string.

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Generic Exception raised on HLS authentication failure instead of GXDLMSException
  • DLMS Image Transfer: “byte must be in range(0, 256)” with 512-byte block size in Python
  • Connecting to meter using Wrapper
  • DLMS Server / Meter emulation in Golang library
  • Unknown Baudrate
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin