Skip to content

Capture the reason why failed to establish association #931

@evergreen-shankar

Description

@evergreen-shankar

Hi, I have an application which performs C-ECHO, C-FIND, C-STORE and C-MOVE. I would like to capture the reason when the association fails while performing these tasks. I have tried with following codebase.

from pynetdicom.sop_class import VerificationSOPClass
from pynetdicom import AE

# Initialise the Application Entity
ae = AE()

# Add a requested presentation context
ae.add_requested_context(VerificationSOPClass)

# Associate with peer AE at IP 127.0.0.1 and port 11112
try:
    assoc = ae.associate('127.0.0.1', 11112)
    if assoc.is_established:
        print("Association established successfully!")
    elif assoc.is_rejected:
        msg = ('{0}: {1}'.format(
            assoc.acceptor.primitive.result_str,
            assoc.acceptor.primitive.reason_str
        ))
        print(msg)
    elif assoc.is_aborted:
        # Capture the aborted reason
        pass
    else:
        # Capture the any other reason why failed to establish association
        print("Failed to establish association.")
except Exception as e:
    print("Failed to establish association. Reason:", e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions