Issue93

Title OnMoveCallback error
Priority bug Status resolved
Superseder Nosy List admin
Assigned To
Keywords Orthanc Core

Created on 2018-06-11.01:29:45 by admin, last changed by admin.

Messages
msg422 (view) Author: admin Date: 2018-06-11.01:29:45
[BitBucket date: 2018-06-10.23:29:45]

Hi all,

I am developing (trying) a plugin. I need to check all the move request(find too) and, depending the modality that asks, index new studies from other dicom servers.
When I create a move request using dcmtk, i get this:
I:
E: Move Request Failed: 0006:020e DIMSE Failed to send message
E: 0006:031d TCP I/O Error (Connection reset by peer) occurred in routine: writeDataPDU
E: Move SCU Failed: 0006:020e DIMSE Failed to send message
E: 0006:031d TCP I/O Error (Connection reset by peer) occurred in routine: writeDataPDU
I: Aborting Association
F: Association Abort Failed: 0006:031d TCP I/O Error (Broken pipe) occurred in routine: sendAbortTCP

If I don't use the plugin this does not happen
My log file in verbose mode:

W0609 02:38:25.673379 main.cpp:683] Orthanc has started
W0609 02:38:25.673460 ServerScheduler.cpp:135] The server scheduler has started
E0609 02:39:02.907250 RunnableWorkersPool.cpp:74] Exception while handling some runnable object: Error encountered within the plugin engine

The server seems to works fine. .

I started to code it using the code of sample plugin (this one https://hg.orthanc-server.com/orthanc/file/62cc762d1fb0aec4fb06c986bbb30a90a3ab03b1/Plugins/Samples/Basic/Plugin.c)
At the moment my code is this (simply to check if it executes the callback function):


```
#!c
   #include "orthanc/OrthancCPlugin.h"
    #include <string.h>
    #include <stdio.h>
    static OrthancPluginContext* context = NULL;
    static OrthancPluginGetMoveSize moveSize = NULL;
    static OrthancPluginApplyMove applyMove = NULL;
    static OrthancPluginFreeMove freeMove = NULL;

 

    OrthancPluginMoveCallback * OnMoveCallback (OrthancPluginMoveCallback resourceType, const char *patientId, const char *accessionNumber, const char *studyInstanceUid, const char *seriesInstanceUid, const char *sopInstanceUid, const char *originatorAet, const char *sourceAet, const char *targetAet, uint16_t originatorId)
    {
      OrthancPluginLogWarning(context, "Sample plugin is movecallback");
    }

    ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
    {
      context = c;
      OrthancPluginLogWarning(context, "Sample plugin is initializing");

      /* Register the callbacks */
      OrthancPluginRegisterMoveCallback(context, OnMoveCallback, moveSize, applyMove, freeMove);

      /* Declare several properties of the plugin */
      OrthancPluginSetRootUri(context, "/plugin/hello");
      OrthancPluginSetDescription(context, "This is the description of the TFG plugin that can be seen in Orthanc Explorer.");
    }

    ORTHANC_PLUGINS_API void OrthancPluginFinalize()
    {
      OrthancPluginLogWarning(context, "Sample plugin is finalizing");
    }

    ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
    {
      return "sample";
    }

    ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
    {
      return "1.0";
    }

 
```

 I compiled it just like any other plugin:

cmake .. -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
make

Any help to make orthanc execute correcly the method will be appretiated
msg423 (view) Author: admin Date: 2018-06-11.23:38:23
[BitBucket user: AlbertoSP]
[BitBucket date: 2018-06-11.21:38:23]

Update:
Tried to add the findcallback and it works fine, so the error may be in the extra arguments of registerMoveCallback (freeMove, applyMove and/or moveSize).

The code now is 

```
#!c

  /* Register the callbacks */
  OrthancPluginRegisterMoveCallback(context, (OrthancPluginMoveCallback) OnMoveCallback, moveSize, applyMove, freeMove);
  OrthancPluginRegisterFindCallback(context, (OrthancPluginFindCallback) OnFindCallback);
```
and the method findcallback 
```
#!c

ORTHANC_PLUGINS_API OrthancPluginFindCallback OnFindCallback (OrthancPluginFindAnswers *answers, const OrthancPluginFindQuery *query, const char *issuerAet, const char *calledAet)
{
  OrthancPluginLogWarning(context, "Sample plugin is findcallback");
}
```
msg424 (view) Author: admin Date: 2018-07-26.08:58:41
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2018-07-26.06:58:41]

The "moveSize", "applyMove" and "freeMove" functions cannot be set to NULL.
msg425 (view) Author: admin Date: 2018-07-26.09:03:18
[BitBucket user: AlbertoSP]
[BitBucket date: 2018-07-26.07:03:18]

Which would be a valid values?
msg426 (view) Author: admin Date: 2018-07-26.09:10:58
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2018-07-26.07:10:58]

Check out the SDK documentation: http://sdk.orthanc-server.com/group__DicomCallbacks.html#ga2e9d921421fb9e4687017fb7d1f599c1
History
Date User Action Args
2026-07-29 15:51:22admincreate