rexcardan / Evil-DICOM

A C# DICOM Library
168 stars 98 forks source link

Failed to CSTORE #41

Closed amilian closed 7 years ago

amilian commented 8 years ago

Hi, When I Send CSTORE it not work. I use dcmtk storescp and this piece of code:

var obj = DICOMObject.Read(f);
var store = new DICOMSCU(new Entity(Config.SourceAET, ip, 21012));
var target = new Entity("AN_TEST", Config.TargetIP, Config.TargetPort);
var request = store.GenerateCStoreRequest(obj, Count);
store.SendMessage(request, target);

When debugger arrived to SendMessage it launch a IOException and said:

It has forced the interruption of an existing connection by the remote host

On the another hand the dcmtk storescp said:

W: DcmItem: Length of element (0002,0010) is odd E: DcmElement: TransferSyntaxUID (0002,0010) larger (1198421) than remaining bytes (18) in file, premature end of stream E: DIMSE failure (aborting association): 0006:020d DIMSE: receiveCommand: cmdSet->read() Failed E: 0001:0004 Invalid stream

dolp1234 commented 7 years ago

Did you solved the error? I use Evil-DICOM library 2 month ago. So I'm late to write a solution. I tested C-ECHO and C-STORE Message 7 days ago. I find the error, too. I solved the problem to use wire-shark with DICOM filter. I can't convince to solve perfectly. But you can receive C-STORE Command on your DICOMSCP exactly.

You need to change source code to fix bug. Please change to Line 33 of the file [EvilDICOM/Network/PDUs/PDataTF.cs] like this. DICOMObjectWriter.Write(dw, settings, dicom); --> DICOMObjectWriter.Write(dw, settings, dicom, true);

When this DICOMObject of DICOM Command change Birnary Data, Transfer Syntax FileMeta is included incorrectly. The Transfer Syntax FileMeta is tag (0002, 0010). But Transfer Syntax FileMeta isn't included if this DICOMObject impersonate Sequence.

Best Regards.