Auto routing with sheduler

Hello !
I found a problem with routing when the modality is unavailable, Sébastien already answered such a problem, could you explain in more detail how to apply this patch to me, I use Orthanc on Windows Server.

Here is your answer: https://groups.google.com/d/msg/orthanc-users/EiO4KPVwSbU/C5IKZs88THoJ , is it still relevant? If so please explain in more detail.

Hello.

According to the discussion, the patch has already been applied more than 5 years ago.

(Sébastien, on 2014-09-10)
“FYI, Orthanc 0.8.2 has just been released, with the patch included.”

Could you please share a description of your setup, maybe your configuration and the output of Orthanc when launched with the --verbose flag ?

If you are using the Windows service (i.e. if Orthanc starts as soon as your server starts), please stop the service (Start menu → Run… → “services.msc” —> scroll down to “Orthanc” → double click → STOP

then open a command prompt, navigate to your Orthanc installation folder and launch Orthanc like this :

cd C:\Program Files\Orthanc Server
.\Orthanc.exe --verbose Configuration\

Thanks for the answer! I attached file with the output.

But, maybe I misunderstood the topic, maybe the thing is that I do routing using a lua script? you can tell me how to do it right, so that if the modality is unavailable, routing occurs later when it becomes available?

verbose conf.txt (18.6 KB)

I completely forgot. here is my script:

`

function OnStoredInstance(instanceId, tags, metadata, origin)
– Ignore the instances that result from the present Lua script to
– avoid infinite loops
if origin[‘RequestOrigin’] ~= ‘Lua’ then

– Send the instance to another modality
RestApiPost(‘/modalities/dcm4chee/store’, instanceId)

end
end

`

Hi Alexey,

  • I am sorry, I wasn’t clear : could you please let Orthanc run when launching it with --verbose, then try to reproduce your problem by triggering a routing so that we can see what’s printed in the log ? Indeed, you only pasted the log that’s displayed at Orthanc initialization time.
  • Also, if I understand correctly, simply trying your Lua script and uploading an image WITHOUT dcm4chee running should be enough to reproduce your issue, right ?

Thanks

There i just uploaded some .dcm file.

When dcm4chee available:

`

I0415 18:51:16.758171 OrthancRestApi.cpp:118] Receiving a DICOM file of 14785262 bytes through HTTP
I0415 18:51:16.760171 OrthancRestApi.cpp:118] Receiving a DICOM file of 14785262 bytes through HTTP
I0415 18:51:16.804174 FilesystemStorage.cpp:118] Creating attachment “b61ae3e2-686c-4f35-b6e6-08b84a5f6df4” of “DICOM” type (size: 15MB)
I0415 18:51:16.807177 FilesystemStorage.cpp:118] Creating attachment “01526958-d6c3-4689-af53-dbae4651bb3a” of “DICOM” type (size: 15MB)
I0415 18:51:16.881180 FilesystemStorage.cpp:118] Creating attachment “efecd9b3-8375-47f9-a56d-ec22a93a639c” of “JSON summary of DICOM” type (size: 1MB)
I0415 18:51:16.883180 FilesystemStorage.cpp:118] Creating attachment “f591e290-89ff-4a53-ad50-f1644833ac13” of “JSON summary of DICOM” type (size: 1MB)
I0415 18:51:16.898182 ServerContext.cpp:417] New instance stored
I0415 18:51:16.899182 PluginsManager.cpp:172] New instance has been added to series db0af6d6-6ff9ba07-856384a7-451fb172-a6f545a1, invalidating it
I0415 18:51:16.899182 OrthancPlugins.cpp:1603] Plugin making REST GET call on URI /instances/38f79592-31461312-cf6ed889-845cd3a8-bf3ab7d8 (built-in API)
I0415 18:51:16.909182 FilesystemStorage.cpp:229] Deleting attachment “b61ae3e2-686c-4f35-b6e6-08b84a5f6df4” of type 1
I0415 18:51:16.914185 JobsRegistry.cpp:712] New job submitted with priority 0: eaed0834-1d28-45a1-b5d3-c3e5e48031ec
I0415 18:51:16.916182 JobsEngine.cpp:144] Executing job with priority 0 in worker thread 0: eaed0834-1d28-45a1-b5d3-c3e5e48031ec
I0415 18:51:16.919183 FilesystemStorage.cpp:229] Deleting attachment “f591e290-89ff-4a53-ad50-f1644833ac13” of type 2
I0415 18:51:16.923183 DicomModalityStoreJob.cpp:60] Sending instance 38f79592-31461312-cf6ed889-845cd3a8-bf3ab7d8 to modality “DCM4CHEE”
I0415 18:51:16.926183 ServerContext.cpp:421] Already stored
I0415 18:51:16.928183 FilesystemStorage.cpp:155] Reading attachment “01526958-d6c3-4689-af53-dbae4651bb3a” of “DICOM” content type
I0415 18:51:16.962187 DicomUserConnection.cpp:1024] Opening a DICOM SCU connection from AET “ORTHANC-TEST” to AET “DCM4CHEE” on host 192.168.1.1:402 (manufacturer: Dcm4Chee)
I0415 18:51:41.274399 JobsRegistry.cpp:486] Job has completed with success: eaed0834-1d28-45a1-b5d3-c3e5e48031ec
I0415 18:51:41.282401 JobsRegistry.cpp:712] New job submitted with priority 0: 413317d3-7573-4b53-ab99-467433b4b80e
I0415 18:51:41.286400 JobsEngine.cpp:144] Executing job with priority 0 in worker thread 1: 413317d3-7573-4b53-ab99-467433b4b80e
I0415 18:51:41.289399 DicomModalityStoreJob.cpp:60] Sending instance 38f79592-31461312-cf6ed889-845cd3a8-bf3ab7d8 to modality “DCM4CHEE”
I0415 18:51:41.292398 FilesystemStorage.cpp:155] Reading attachment “01526958-d6c3-4689-af53-dbae4651bb3a” of “DICOM” content type
I0415 18:51:41.325401 DicomUserConnection.cpp:1024] Opening a DICOM SCU connection from AET “ORTHANC-TEST” to AET “DCM4CHEE” on host 192.168.1.1:402 (manufacturer: Dcm4Chee)
I0415 18:52:07.302519 JobsRegistry.cpp:486] Job has completed with success: 413317d3-7573-4b53-ab99-467433b4b80e

`

When dcm4chee unavailable:

`

I0415 18:57:27.241865 OrthancRestApi.cpp:118] Receiving a DICOM file of 14785250 bytes through HTTP
I0415 18:57:27.243863 OrthancRestApi.cpp:118] Receiving a DICOM file of 14785250 bytes through HTTP
I0415 18:57:27.288868 FilesystemStorage.cpp:118] Creating attachment “561717e0-55c8-4bd2-a71b-3036f83f757c” of “DICOM” type (size: 15MB)
I0415 18:57:27.291867 FilesystemStorage.cpp:118] Creating attachment “64af6ddf-7fe8-4813-8294-ad49c90f0fee” of “DICOM” type (size: 15MB)
I0415 18:57:27.361873 FilesystemStorage.cpp:118] Creating attachment “3fc73af8-e0c5-4645-b634-9a16bc0a2da4” of “JSON summary of DICOM” type (size: 1MB)
I0415 18:57:27.368874 FilesystemStorage.cpp:118] Creating attachment “54def84b-9c61-4a3c-a523-8dbb4069cfc9” of “JSON summary of DICOM” type (size: 1MB)
I0415 18:57:27.384875 ServerContext.cpp:417] New instance stored
I0415 18:57:27.384875 PluginsManager.cpp:172] New instance has been added to series 562ed3bc-eb52df2b-84da12c3-f3c4b8b4-a8a53899, invalidating it
I0415 18:57:27.389874 OrthancPlugins.cpp:1603] Plugin making REST GET call on URI /instances/02f6c3d5-3de136d4-8f1be5a8-9aa2d681-853f2b76 (built-in API)
I0415 18:57:27.394874 FilesystemStorage.cpp:229] Deleting attachment “64af6ddf-7fe8-4813-8294-ad49c90f0fee” of type 1
I0415 18:57:27.398877 JobsRegistry.cpp:712] New job submitted with priority 0: 9fcc0cfa-6a02-41bd-8055-ac2122e6ec76
I0415 18:57:27.402877 FilesystemStorage.cpp:229] Deleting attachment “54def84b-9c61-4a3c-a523-8dbb4069cfc9” of type 2
I0415 18:57:27.402877 JobsEngine.cpp:144] Executing job with priority 0 in worker thread 1: 9fcc0cfa-6a02-41bd-8055-ac2122e6ec76
I0415 18:57:27.408876 ServerContext.cpp:421] Already stored
I0415 18:57:27.410876 DicomModalityStoreJob.cpp:60] Sending instance 02f6c3d5-3de136d4-8f1be5a8-9aa2d681-853f2b76 to modality “DCM4CHEE”
I0415 18:57:27.415876 FilesystemStorage.cpp:155] Reading attachment “561717e0-55c8-4bd2-a71b-3036f83f757c” of “DICOM” content type
I0415 18:57:27.450879 DicomUserConnection.cpp:1024] Opening a DICOM SCU connection from AET “ORTHANC-TEST” to AET “DCM4CHEE” on host 192.168.1.1:402 (manufacturer: Dcm4Chee)
E0415 18:57:37.457581 OrthancException.h:85] Error in the network protocol: DicomUserConnection - connecting to AET “DCM4CHEE”: Failed to establish association (0006:0317 Peer aborted Association (or never connected); 0006:031c TCP Initialization Error: ╬яхЁрЎш єёях°эю чртхЁ°хэр. (Timeout))
I0415 18:57:37.475563 JobsRegistry.cpp:486] Job has completed with success: 9fcc0cfa-6a02-41bd-8055-ac2122e6ec76
E0415 18:57:37.479562 OrthancException.h:85] Error in the network protocol: DicomUserConnection - connecting to AET “DCM4CHEE”: Failed to establish association (0006:0317 Peer aborted Association (or never connected); 0006:031c TCP Initialization Error: ╬яхЁрЎш єёях°эю чртхЁ°хэр. (Timeout))
E0415 18:57:37.487563 LuaScripting.cpp:358] Lua: Error in the network protocol
E0415 18:57:37.490564 LuaScripting.cpp:361] Lua: Error in RestApiPost() for URI: /modalities/dcm4chee/store
I0415 18:57:37.495783 JobsRegistry.cpp:712] New job submitted with priority 0: 5dcd3919-3d07-4e4f-8ba8-0a4eb2df6463
I0415 18:57:37.498784 JobsEngine.cpp:144] Executing job with priority 0 in worker thread 0: 5dcd3919-3d07-4e4f-8ba8-0a4eb2df6463
I0415 18:57:37.500784 DicomModalityStoreJob.cpp:60] Sending instance 02f6c3d5-3de136d4-8f1be5a8-9aa2d681-853f2b76 to modality “DCM4CHEE”
I0415 18:57:37.503983 FilesystemStorage.cpp:155] Reading attachment “561717e0-55c8-4bd2-a71b-3036f83f757c” of “DICOM” content type
I0415 18:57:37.532985 DicomUserConnection.cpp:1024] Opening a DICOM SCU connection from AET “ORTHANC-TEST” to AET “DCM4CHEE” on host 192.168.1.1:402 (manufacturer: Dcm4Chee)
E0415 18:57:47.537981 OrthancException.h:85] Error in the network protocol: DicomUserConnection - connecting to AET “DCM4CHEE”: Failed to establish association (0006:0317 Peer aborted Association (or never connected); 0006:031c TCP Initialization Error: ╬яхЁрЎш єёях°эю чртхЁ°хэр. (Timeout))
I0415 18:57:47.549507 JobsRegistry.cpp:486] Job has completed with success: 5dcd3919-3d07-4e4f-8ba8-0a4eb2df6463
E0415 18:57:47.551506 OrthancException.h:85] Error in the network protocol: DicomUserConnection - connecting to AET “DCM4CHEE”: Failed to establish association (0006:0317 Peer aborted Association (or never connected); 0006:031c TCP Initialization Error: ╬яхЁрЎш єёях°эю чртхЁ°хэр. (Timeout))
E0415 18:57:47.564507 LuaScripting.cpp:358] Lua: Error in the network protocol
E0415 18:57:47.565509 LuaScripting.cpp:361] Lua: Error in RestApiPost() for URI: /modalities/dcm4chee/store

`

After that, I return dcm4chee availability, but nothing happens. I try to upload another file when dcm4chee is available and then it is sent to dcm4chee. File that was uploaded while dcm4chee was unavailable is simply lost for dcm4chee.

Alexey,

The fix that was mentioned years ago was about a bug : Orthanc seemingly (I wasn’t there at the time :slight_smile: seemingly behaved incorrectly when the modality was unreachable.

Your situation is very different. With all due respect, it seems to me that you are requesting a feature : the ability for Orthanc to retry to route instances that were missed the first time.

However, in your scenario, Orthanc simply executes a Lua script and does not really “know” what the script is doing! For all purposes, it could do something else than route (print the id, modify the dicom instance…)

If you wish to ensure the instances are routed to your other modality, I think that you need, in addition to routing, use some sort of external DB (or even file, if the data volume isn’t that big) to write down the IDs of all the instances, so that you can, from time to time, run an external script that will retry the failed routing attempts.

You might want to have a look at the following Python script : https://bitbucket.org/sjodogne/orthanc/src/default/Resources/Samples/Python/HighPerformanceAutoRouting.py

What it does is handle routing without blocking Orthanc, by doing it externally in a script that you can launch.

What you should do is modify it to add error handling (the return value of RestToolbox.DoPost(‘%s/modalities/sample/store’ % URL, instances) at line 115) to only remove the instance(s) from the queue if the transfer is successful (WARNING : the script as it is also deletes instances from Orthanc after transfer)

An alternative option is to use the Orthanc jobs engine. You might want to read this post from the group that describes a use case similar to yours: https://groups.google.com/forum/#!searchin/orthanc-users/jobs$20retry%7Csort:date/orthanc-users/ymhOt3BPBUs/5pJBzMqdBgAJ

Hope this helps.

Thanks a lot for your answers, Benjamin! I read the post that you proposed, now it’s clear that the orthanc saves jobs that were not completed, they can even be done manually later, when the modality is available.