Store SCP Failed: DIMSE: Odd Fragment Length when sending EncapsulatedPDF with odd ValueLength

Hi,

I’m working on sending and encapsulatedPDF through a python script to the Orthanc Server. On the first try I obtained this log:

Store SCP Failed: DIMSE: Odd Fragment Length: 1275

Then, as suggested in this thread I ran the storescp utility and obtained this output:

D: Association Received: kubernetes
D: setting network send timeout to 60 seconds
D: setting network receive timeout to 60 seconds
D: PDU Type: Associate Request, PDU Length: 293 + 6 bytes PDU header
D: 01 00 00 00 01 25 00 01 00 00 41 4e 59 2d 53 43
D: 50 20 20 20 20 20 20 20 20 20 50 59 4e 45 54 44
D: 49 43 4f 4d 20 20 20 20 20 20 00 00 00 00 00 00
D: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
D: 00 00 00 00 00 00 00 00 00 00 10 00 00 15 31 2e
D: 32 2e 38 34 30 2e 31 30 30 30 38 2e 33 2e 31 2e
D: 31 2e 31 20 00 00 82 01 00 00 00 30 00 00 1d 31
D: 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 35 2e 31
D: 2e 34 2e 31 2e 31 2e 31 30 34 2e 31 40 00 00 11
D: 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e
D: 32 40 00 00 13 31 2e 32 2e 38 34 30 2e 31 30 30
D: 30 38 2e 31 2e 32 2e 31 40 00 00 16 31 2e 32 2e
D: 38 34 30 2e 31 30 30 30 38 2e 31 2e 32 2e 31 2e
D: 39 39 40 00 00 13 31 2e 32 2e 38 34 30 2e 31 30
D: 30 30 38 2e 31 2e 32 2e 32 50 00 00 3e 51 00 00
D: 04 00 00 3f fe 52 00 00 20 31 2e 32 2e 38 32 36
D: 2e 30 2e 31 2e 33 36 38 30 30 34 33 2e 39 2e 33
D: 38 31 31 2e 31 2e 35 2e 37 55 00 00 0e 50 59 4e
D: 45 54 44 49 43 4f 4d 5f 31 35 37
D: Parsing an A-ASSOCIATE PDU
I: Association Received
D: Parameters:
D: ====================== BEGIN A-ASSOCIATE-RQ =====================
D: Our Implementation Class UID: 1.2.276.0.7230010.3.0.3.6.6
D: Our Implementation Version Name: OFFIS_DCMTK_366
D: Their Implementation Class UID: 1.2.826.0.1.3680043.9.3811.1.5.7
D: Their Implementation Version Name: PYNETDICOM_157
D: Application Context Name: 1.2.840.10008.3.1.1.1
D: Calling Application Name: PYNETDICOM
D: Called Application Name: ANY-SCP
D: Responding Application Name:
D: Our Max PDU Receive Size: 16384
D: Their Max PDU Receive Size: 16382
D: Presentation Contexts:
D: Context ID: 1 (Proposed)
D: Abstract Syntax: =EncapsulatedPDFStorage
D: Proposed SCP/SCU Role: Default
D: Proposed Transfer Syntax(es):
D: =LittleEndianImplicit
D: =LittleEndianExplicit
D: =DeflatedLittleEndianExplicit
D: =BigEndianExplicit
D: Requested Extended Negotiation: none
D: Accepted Extended Negotiation: none
D: Requested User Identity Negotiation: none
D: User Identity Negotiation Response: none
D: ======================= END A-ASSOCIATE-RQ ======================
D: Constructing Associate AC PDU
I: Association Acknowledged (Max Send PDV: 16370)
D: ====================== BEGIN A-ASSOCIATE-AC =====================
D: Our Implementation Class UID: 1.2.276.0.7230010.3.0.3.6.6
D: Our Implementation Version Name: OFFIS_DCMTK_366
D: Their Implementation Class UID: 1.2.826.0.1.3680043.9.3811.1.5.7
D: Their Implementation Version Name: PYNETDICOM_157
D: Application Context Name: 1.2.840.10008.3.1.1.1
D: Calling Application Name: PYNETDICOM
D: Called Application Name: ANY-SCP
D: Responding Application Name: ANY-SCP
D: Our Max PDU Receive Size: 16384
D: Their Max PDU Receive Size: 16382
D: Presentation Contexts:
D: Context ID: 1 (Accepted)
D: Abstract Syntax: =EncapsulatedPDFStorage
D: Proposed SCP/SCU Role: Default
D: Accepted SCP/SCU Role: Default
D: Accepted Transfer Syntax: =DeflatedLittleEndianExplicit
D: Requested Extended Negotiation: none
D: Accepted Extended Negotiation: none
D: Requested User Identity Negotiation: none
D: User Identity Negotiation Response: none
D: ======================= END A-ASSOCIATE-AC ======================
D: DcmDataset::read() TransferSyntax=“Little Endian Implicit”
I: Received Store Request
D: ===================== INCOMING DIMSE MESSAGE ====================
D: Message Type : C-STORE RQ
D: Presentation Context ID : 1
D: Message ID : 1
D: Affected SOP Class UID : EncapsulatedPDFStorage
D: Affected SOP Instance UID : 1.9.9.12552625481111022022
D: Data Set : present
D: Priority : low
D: ======================= END DIMSE MESSAGE =======================
D: DcmDataset::read() TransferSyntax=“Deflated Explicit VR Little Endian”
W: DcmItem: Length of element (0042,0011) is odd
I: storing DICOM file: .\PDF.1.9.9.12552625481111022022
D: DcmFileFormat::checkMetaHeaderValue() Version of MetaHeader is ok: 0x0001
D: DcmFileFormat::checkMetaHeaderValue() use SOPClassUID [1.2.840.10008.5.1.4.1.1.104.1] from Dataset
D: DcmFileFormat::checkMetaHeaderValue() use SOPInstanceUID [1.9.9.12552625481111022022] from Dataset
D: DcmFileFormat::checkMetaHeaderValue() use new TransferSyntaxUID [Deflated Explicit VR Little Endian] on writing following Dataset
D: DcmFileFormat::validateMetaInfo() found 8 Elements in DcmMetaInfo ‘metinf’
I: Association Release

So the transmission worked and the association is not aborted or timed out as in the Orthanc case. However, the utility highlighted that the value length of element (0042, 0011) (The document encapsulated) is odd, while every DICOM element must have an even value length. Then I investigated further and found that the DICOM standard implements this element where you can specify the Value Length of (0042, 0011), even if it’s odd. However, even after adding this element, I obtained the same result from Orthanc:

Store SCP Failed: DIMSE: Odd Fragment Length: 1287

While the storescp utility worked as before with the warning on (0042, 0011). In the end, I managed this padding the pdf to an even value length, appending a ‘\0’ at the end of the file, but is this the right behavior from Orthanc? Thank you.

Hello,

I thank you for this detailed investigation, but you must provide us with a minimal working example:
https://book.orthanc-server.com/users/support.html#discussing-a-minimal-working-example

Without this example, we cannot reproduce your issue and cannot give any direction. Please provide a least a sample (possibly anonymized) DICOM file, or a PDF file, and the “curl” command-line you used.

Kind Regards,
Sébastien-