fo-dicom / fo-dicom-samples

Sample applications associated with the fo-dicom framework
Other
153 stars 143 forks source link

PrintSCP error on empty request.SOPInstanceUID #4

Closed AhmedSamak101 closed 7 years ago

AhmedSamak101 commented 7 years ago

Hello Team, I try to create a print server using foo-dicom. the software successfully created a print job for HITACHI MRI modality, but when I tried to use it on FUJI FCR I got the error below. the error also appeared when I print your provided sample file from ClearCanvas Workstation.

As shown below, the error appears on the ActionRequest. I tried to keep the last request.SOPInstanceID from the SetResponse by editing DicomService.cs and provided the SOPInstanceID when the error appeared but I got the error "Received N-ACTION request for invalid film box "

Please advise how to overcome the issue. Thank you in advance Best regards, Ahmed Samak

=========Logs & ERROR============= Starting print SCP server with AET: DV5700 on port 5040 Press any key to stop the service AHMEDSNB-8 <- Association request: Calling AE Title: AHMEDSNB-8 Called AE Title: DV5700 Remote host: 10.10.10.219 Remote port: 22629 Implementation Class: Implementation Class UID [1.3.6.1.4.1.25403.1.1.1] Implementation Version: Dicom 0.1 Maximum PDU Length: 116794 Async Ops Invoked: 1 Async Ops Performed: 1 Presentation Contexts: 1 Presentation Context: 1 [Proposed] Abstract Syntax: Basic Grayscale Print Management Meta SOP Class Transfer Syntax: Explicit VR Little Endian Transfer Syntax: Implicit VR Little Endian: Default Transfer Syntax for DICOM Received association request from AE: AHMEDSNB-8 with IP: 127.0.0.1 Accepted association request from AHMEDSNB-8 AHMEDSNB-8 -> Association accept: Calling AE Title: AHMEDSNB-8 Called AE Title: DV5700 Remote host: 10.10.10.219 Remote port: 22629 Implementation Class: Implementation Class UID [1.3.6.1.4.1.25403.1.1.1] Implementation Version: Dicom 0.1 Maximum PDU Length: 116794 Async Ops Invoked: 1 Async Ops Performed: 1 Presentation Contexts: 1 Presentation Context: 1 [Accept] Abstract Syntax: Basic Grayscale Print Management Meta SOP Class Transfer Syntax: Explicit VR Little Endian AHMEDSNB-8 <- N-Create request [1] Create new film session 2.25.56646666487928587586720110208669504892 AHMEDSNB-8 -> N-Create response [1]: Success AHMEDSNB-8 <- N-Create request [2] Applying display format STANDARD\1,1 for film box SOP Instance UID [1.3.6.1.4.1.30071.8.269070623445363.5452238343298712] Created new film box 1.3.6.1.4.1.30071.8.269070623445363.5452238343298712 AHMEDSNB-8 -> N-Create response [2]: Success AHMEDSNB-8 <- N-Set request [3] Set image box 1.3.6.1.4.1.30071.8.269070623445363.5452238343298712.1 AHMEDSNB-8 -> N-Set response [3]: Success AHMEDSNB-8 <- N-Action request [4] Action Type: 0001 Exception processing P-Data-TF PDU: Dicom.DicomDataException: Element empty or index: 0 exceeds element count: 0 at Dicom.DicomDataset.Get[T](DicomTag tag, Int32 n, Boolean useDefault, T defaultValue) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\DicomDataset.cs:line 507 at Dicom.DicomDataset.Get[T](DicomTag tag, Int32 n) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\DicomDataset.cs:line 118 at Dicom.Network.DicomNActionRequest.get_SOPInstanceUID() in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomNActionRequest.cs:line 51 at Dicom.Printing.PrintService.OnNActionRequest(DicomNActionRequest request) in D:\GBNProjects\dicom\fo-dicom-samples-master\fo-dicom-samples-master\Desktop\Print SCP\PrintService.cs:line 646 at Dicom.Network.DicomService.PerformDimse(DicomMessage dimse) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomService.cs:line 841 at Dicom.Network.DicomService.d__58.MoveNext() in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomService.cs:line 663 Exception processing PDU: Dicom.DicomDataException: Element empty or index: 0 exceeds element count: 0 at Dicom.DicomDataset.Get[T](DicomTag tag, Int32 n, Boolean useDefault, T defaultValue) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\DicomDataset.cs:line 507 at Dicom.DicomDataset.Get[T](DicomTag tag, Int32 n) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\DicomDataset.cs:line 118 at Dicom.Network.DicomNActionRequest.get_SOPInstanceUID() in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomNActionRequest.cs:line 51 at Dicom.Printing.PrintService.OnNActionRequest(DicomNActionRequest request) in D:\GBNProjects\dicom\fo-dicom-samples-master\fo-dicom-samples-master\Desktop\Print SCP\PrintService.cs:line 646 at Dicom.Network.DicomService.PerformDimse(DicomMessage dimse) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomService.cs:line 841 at Dicom.Network.DicomService.d58.MoveNext() in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomService.cs:line 732 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at Dicom.Network.DicomService.d57.MoveNext() in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomService.cs:line 457 Connection closed Error during close attempt: Dicom.DicomDataException: Element empty or index: 0 exceeds element count: 0 at Dicom.Network.DicomService.TryCloseConnection(Exception exception, Boolean force) in D:\GBNProjects\dicom\fo-dicom-development\fo-dicom-development\DICOM\Network\DicomService.cs:line 1109

anders9ustafsson commented 7 years ago

@AhmedSamak101 This problem seems to relate to a recently fixed bug in fo-dicom, fo-dicom/fo-dicom#484 . The bug fix has not been included in any release yet, but if you want to check it right away, please download and build either the development or 3.0 branch from source, and include the build in your Print SCP application.

AhmedSamak101 commented 7 years ago

@anders9ustafsson Thank you for your prompt response. I think it's not related to #484, I already work with development branch and the SCP sample has the source projects as references Dicom.Core & Dicom.Native64. however I got a fresh clone of development and the error still persist. The second note that the problem at #485 was "the argument was null" while our problem now is the element RequestedSOPInstanceUID is not presented at all . I don't know why it is not sent from the source in the fourth request "N-Action Request". What do you think? Thank you

anders9ustafsson commented 7 years ago

@AhmedSamak101 OK, I might have been too quick. Apparently, the code fails to access the SOP Instance UID of the N-ACTION request. According to the standard the Requested SOP Instance UID of the N-ACTION request is mandatory, so it is an error that it cannot be found in the request.

Right away I am not sure if the root cause for the missing UID is in fo-dicom or in the FUJI software. To find out, you can switch on a debug flag in fo-dicom to get the full request data in the log: just set the DicomService Options.LogDimseDatasets to true.

AhmedSamak101 commented 7 years ago

@anders9ustafsson Well, I turned on the debug flag and I got the attached results. Note about the error log: According to the attached logs I think the root cause started when the software attempted to "Create new film session" please try to find the UID provided with "create new film session" in the in the two files, you will find it once in the fail-xx file while you will find it 6 times in the success-xx file. General Notes: foo-dicom successfully printed from MRI modality and your provided samples with Print SCU. FUJI successfully prints to it's physical printer "DRYPIX Smart". foo-dicom couldn't successfully receive jobs from FUJI modality and ClearCanvas Workstation.

Would that help understanding the exception? Thanks

success-missing-sop-instance-uid-investigation.txt fail-missing-sop-instance-uid-investigation.txt

AhmedSamak101 commented 7 years ago

Hello again! @anders9ustafsson After comparison between the logs from fail and success printing jobs I found the root cause of the issue, the modality or ClearCanvas sends the request without SOPInstanceUID so what I did is after creating a new film I provided the generated SOPInstanceUID of _filmSession the the create response as below:

if (request.SOPInstanceUID == null || request.SOPInstanceUID.UID == string.Empty)
            {
                request.Command.AddOrUpdate(DicomTag.AffectedSOPInstanceUID, _filmSession.SOPInstanceUID);
            }

Then I did the same for the next response directly after creating the film box as below:

if (request.SOPInstanceUID == null || request.SOPInstanceUID.UID == string.Empty)
            {
                request.Command.AddOrUpdate(DicomTag.AffectedSOPInstanceUID, filmBox.SOPInstanceUID.UID);
            }

I assume the case will be the same at the FUJI maodality, hopefully and I'll make a pull request for the changes. Thank you for the debug flag :)