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 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.

eriktrif

17 hours ago

Hi I'm sorry! I accidentally…

Hi I'm sorry! I accidentally created this thread on the forum instead of in the bug tracker.

Profile picture for user Kurumi

Kurumi

17 sec ago

Hi, It's always better to…

Hi,

It's always better to talk in the forum first than to create a bug report. Especially in a case like this.

initializeConnection exception handling solves a different problem. Some meters reply with all kinds of errors, and this handles that case.

I really understand your idea, but I need to verify with the customers whether using AUTHENTICATION_FAILURE will cause problems or if there are other problems it might cause.

Regards,
Mikko

  • 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

  • L+G E355 Load Control
  • 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
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin