DIMSE_sendCancelRequest problem

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
geke
Posts: 6
Joined: Mon, 2017-07-17, 15:33

DIMSE_sendCancelRequest problem

#1 Post by geke »

Hello,

I have a "problem" with the cancelling of an query request.

i use a DcmFindScu based implementation. When cancelling the query i sent DIMSE_sendCancelRequest from the callback. Is this correct? Are there any examples i have missed (couldn't find any).

Code: Select all

void MyCallback::callback
( T_DIMSE_C_FindRQ *request, int responseCount, T_DIMSE_C_FindRSP *rsp,
  DcmDataset *responseIdentifiers )
{
  qDebug() << "rsp " << rsp->DimseStatus;
  /* send C-FIND-CANCEL */
  if( responseCount > m_cancelAfterNResponses )
  {
    if( !m_cancelRequestSent )
    {
      DCMNET_INFO("Sending Cancel Request (MsgID " << request->MessageID
                  << ", PresID " << OFstatic_cast(unsigned int, presId_)
                  << ")");
      OFCondition cond = DIMSE_sendCancelRequest(assoc_, presId_,
                                                 request->MessageID);
      if (cond.bad())
      {
        OFString temp_str;
        DCMNET_ERROR("Cancel Request Failed: "
                     << DimseCondition::dump(temp_str, cond));
      } else m_cancelRequestSent = true;
    }

    emit maxResponsesReached();
    return;
  }
  ...
}
After execution i get the following output:
  • ...
    rsp 65280
    W: DcmItem: Invalid Element (0002,0003) found in data set
    rsp 65280
    I: Sending Cancel Request (MsgID 1, PresID 1)
    W: DcmItem: Invalid Element (0002,0003) found in data set
    rsp 65280
    ...
    W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): findUser: Status Cancel: MatchingTerminatedDueToCancelRequest, but DataSetType!=NULL
    W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): Assuming no response identifiers are present
    I: Received Final Find Response (Cancel: MatchingTerminatedDueToCancelRequest)
    I: Releasing Association
    E: Association Release Failed: 0006:0316 DUL P-Data PDU arrived
There should be different statuses of the response:

a) Success
b) Pending
c) Refused
d) Refused
e) Refused
f) Cancel
g) Failed

How can i get it? rsp->DimseStatus is always 65280.

What does the warnings:
W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): findUser: Status Cancel: MatchingTerminatedDueToCancelRequest, but DataSetType!=NULL
W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): Assuming no response identifiers are present
and error:
E: Association Release Failed: 0006:0316 DUL P-Data PDU arrived mean?

Greetings Gerd

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: DIMSE_sendCancelRequest problem

#2 Post by Michael Onken »

Hi Gerd,

let's go through this:
geke wrote:Hello,

I have a "problem" with the cancelling of an query request.

i use a DcmFindScu based implementation. When cancelling the query i sent DIMSE_sendCancelRequest from the callback. Is this correct? Are there any examples i have missed (couldn't find any).
Looks good to me at first sight.
After execution i get the following output:

Code: Select all

...
rsp  65280
65280 is hexadecimal FF00 which again is status PENDING according to the related section DICOM standard part 7.
That is the correct status when the server sends you a query response that is not the last one.

Code: Select all

W: DcmItem: Invalid Element (0002,0003) found in data set
The element 0002,0003 is the Media Storage SOP Instance UID. This is never allowed on the network, so this is a problem of the server. DCMTK does not care too much, it just warns about it.

Code: Select all

rsp  65280
I: Sending Cancel Request (MsgID 1, PresID 1)
W: DcmItem: Invalid Element (0002,0003) found in data set
rsp  65280
...
Another C-FIND response with status PENDING from the server, then your cancel request is sent (warning as explained above). After your C-FIND-CANCEL, another PENDING response comes in. This is permitted, since the server might have provided some responses already to the network or a software layer that it cannot "control". DICOM explicitly permits to send some remaining C-FIND responses after sending the cancel. Also note that at this point the server did not acknowledge your cancel request yet.

Code: Select all

W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): findUser: Status Cancel: MatchingTerminatedDueToCancelRequest, but DataSetType!=NULL
W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): Assuming no response identifiers are present
Now your code has received the cancel acknowledgement of the server. But it warns that the message announces to contain a dataset. This is not permitted in DICOM, since the cancel ack message does not contain any dataset payload per definition. Anyway, DCMTK warns about this and assumes that the announcement that a dataset is attached is wrong.

Code: Select all

I: Received Final Find Response (Cancel: MatchingTerminatedDueToCancelRequest)
I: Releasing Association
As expected DCMTK interprets the cancel acknowledgement as last message, since afterwards the server is not permitted to send any more responses (in status PENDING). Thus it releases the connection.

Code: Select all

E: Association Release Failed: 0006:0316 DUL P-Data PDU arrived
However, surprisingly, the server still sends some data, maybe the announced (but not permitted) dataset of the cancel acknowledgement. Since DCMTK assumed that there is no such dataset, it prints an error since for DCMTK such a message is not allowed after a association release.
There should be different statuses of the response:
a) Success
b) Pending
c) Refused
d) Refused
e) Refused
f) Cancel
g) Failed

How can i get it? rsp->DimseStatus is always 65280.
...which means PENDING as explained above. If you like to see the status string, there is a function to produce that from the status code. You can find it in diutil.h/cc: DU_cfindStatusString(Uint16 status). It is also used in dfindscu.cc, for example.

As a takeaway: The server announces (and probably also sends) a dataset after its cancel acknowledgement, where it is not permitted. DCMTK assumes there is no dataset (since its against the rules) and closes the association since the C-FIND operation is done from the client's point of view. Then it gets surprised by receiving a data package instead of a release response.

All clear now :)?

Best regards,
Michael

geke
Posts: 6
Joined: Mon, 2017-07-17, 15:33

Re: DIMSE_sendCancelRequest problem

#3 Post by geke »

Hello Michael,

W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): findUser: Status Cancel: MatchingTerminatedDueToCancelRequest, but DataSetType!=NULL
W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): Assuming no response identifiers are present
E: Association Release Failed: 0006:0316 DUL P-Data PDU arrived

As you explained the Error seems to be of an non conformant PACS (I used Orthanc).

For further testing i now use DVTK Q&R SCP, which should be more conform.

But still in my callback i only see a pending state. The success message is written in the DCMTK log. But how can i catch the success, refused, cancel or failed state in my code?

Or better asked does it make sense to check them in the callback? But how can i detect a failed query then?
The element 0002,0003 is the Media Storage SOP Instance UID. This is never allowed on the network, so this is a problem of the server. DCMTK does not care too much, it just warns about it.
I saw your reply at the dicom newsgroup
https://groups.google.com/forum/?hl=de# ... MrrtRWhcuU

I now use DcmDataset::removeInvalidGroups(); before the dataset is stored to PACS. I think this function is intended for the "problem" you explained at the dicom newsgroup.

Greetings Gerd

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: DIMSE_sendCancelRequest problem

#4 Post by Michael Onken »

Hi Gerd,

have you tried the same thing using findscu (sending cancel?)?
If this works, dig into the findscu.cc code (which uses dfindscu.cc) to see how things work. I would also now go into that code and look it up.

Best,
Michael

geke
Posts: 6
Joined: Mon, 2017-07-17, 15:33

Re: DIMSE_sendCancelRequest problem

#5 Post by geke »

Hello Michael,

I tried it with findscu: It produces the same error. The problem is not my code/implementation. I will post this topic in the ORTHANC forum.

Greeting Gerd

Code: Select all

findscu -v --cancel 10 -P -aec ORTHANC -aet MY_SCU localhost 4242 -k QueryRetrieveLevel=IMAGE
I: Find Response: 280 (Pending)
I:
I: # Dicom-Data-Set
I: # Used TransferSyntax: Little Endian Explicit
I: (0008,0005) CS [ISO_IR 100] # 10, 1 SpecificCharacterSet
I: (0008,0052) CS [IMAGE ] # 6, 1 QueryRetrieveLevel
I:
W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): findUser: Status Cancel: MatchingTerminatedDueToCancelRequest, but DataSetType!=NULL
W: DIMSE Warning: (ISEEPROSTORESCP,ORTHANC): Assuming no response identifiers are present
I: Received Final Find Response (Cancel: MatchingTerminatedDueToCancelRequest)
I: Releasing Association
E: Association Release Failed: 0006:0316 DUL P-Data PDU arrived

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest