pydicom / pynetdicom

A Python implementation of the DICOM networking protocol
https://pydicom.github.io/pynetdicom
MIT License
500 stars 176 forks source link

Invalid 'Called AE Title' value 'PYNETDICOME: Unable to decode the received PDU data #921

Closed EmilioAHV closed 4 months ago

EmilioAHV commented 5 months ago

Hello everyone, I tried to connect a Workstation with eFilm to my SCP, so i could understand what services does this software use but i get this error:

E: Invalid 'Called AE Title' value 'PYNETDICOM
E: Unable to decode the received PDU data
E: Invalid 'Called AE Title' value 'PYNETDICOM
D: Abort Parameters:
D: =========================== OUTGOING A-ABORT PDU ===========================
D: Abort Source: DUL service-user
D: Abort Reason: (no value available)
D: ============================= END A-ABORT PDU ==============================

I've ran the debug_data function from @scaramallion, this is the code and the output:

from pynetdicom import AE, debug_logger, evt, AllStoragePresentationContexts
from pynetdicom.utils import pretty_bytes
from pynetdicom.sop_class import VerificationSOPClass

debug_logger()

def debug_data(event):
    data = event.data
    if data[0] != 0x01:
        return

    slist = pretty_bytes(
        data, prefix=' ', delimiter=' ', max_size=None, items_per_line=25
    )
    for s in slist:
        print(s)

def handle_store(event):
    return 0x0000

hh = [(evt.EVT_DATA_RECV, debug_data), (evt.EVT_C_STORE, handle_store)]
ae = AE()
ae.supported_contexts = AllStoragePresentationContexts
ae.add_supported_context(VerificationSOPClass)
ae.start_server(('', 11112), evt_handlers=hh)
01 00 00 00 01 4f 00 01 00 00 50 59 4e 45 54 44 49 43 4f 4d 00 20 20 20 20
 20 45 46 49 4c 4d 00 20 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10
 00 00 15 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 33 2e 31 2e 31 2e 31 20
 00 00 38 01 00 00 00 30 00 00 1b 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e
 35 2e 31 2e 34 2e 31 2e 31 2e 31 2e 31 40 00 00 11 31 2e 32 2e 38 34 30 2e
 31 30 30 30 38 2e 31 2e 32 20 00 00 66 03 00 00 00 30 00 00 1b 31 2e 32 2e
 38 34 30 2e 31 30 30 30 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 31 2e 31 40 00
 00 13 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e 32 2e 31 40 00 00 13
 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e 32 2e 32 40 00 00 11 31 2e
 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e 32 50 00 00 48 51 00 00 04 00 00
 fa ea 52 00 00 10 31 2e 32 2e 38 30 34 2e 31 31 34 31 31 38 2e 33 54 00 00
 1f 00 1b 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 35 2e 31 2e 34 2e 31 2e
 31 2e 31 2e 31 01 00 55 00 00 05 65 46 69 6c 6d
E: Invalid 'Called AE Title' value 'PYNETDICOM
E: Unable to decode the received PDU data
E: Invalid 'Called AE Title' value 'PYNETDICOM
D: Abort Parameters:
D: =========================== OUTGOING A-ABORT PDU ===========================
D: Abort Source: DUL service-user
D: Abort Reason: (no value available)
D: ============================= END A-ABORT PDU ==============================
-DECODED: 
PYNETDICOM     EFILM          1.2.840.10008.3.1.1.1 80  1.2.840.10008.5.1.4.1.1.1.1@  1.2.840.10008.1.2 f0 
  1.2.840.10008.5.1.4.1.1.1.1@  1.2.840.10008.1.2.1@  1.2.840.10008.1.2.2@1.2.840.10008.1.2PHQ

I would really appreciate your help with this problem

scaramallion commented 5 months ago

The encoded AE titles are:

50 59 4e 45 54 44 49 43 4f 4d 00 20 20 20 20 20  # PYNETDICOM + null + 5 spaces
45 46 49 4c 4d 00 20 20 20 20 20 20 20 20 20 20  # EFILE + null + 10 spaces

ASCII null (0x00) is not a valid character for an AE title which should be one of the values in this table.

You may be able to bypass this by setting your own AE validator with _config.VALIDATORS

EmilioAHV commented 4 months ago

Hi @scaramallion

Just returning from vacations, I've tried both things (to complete the null values with spaces "EFILE " and modifying the AE validator. Both approaches seemed solid, but for assessment purposes, your debug_data method was a game-changer. Now, I can tell exactly why the printer couldn't connect to this viewer (because in Weasis or Radiant work just fine). Thanks for the insight!"

scaramallion commented 4 months ago

No problem, glad you figured it out