Transfers accelerator with Lua script

Hi everyone,

I am running the Orthanc server on docker with TRANSFERS_PLUGIN_ENABLED and I would like to use it to send data to a remote Orthanc server through the P2P connection established through a Lua script.

function OnStableStudy(studyId, tags, metadata) 
    local moveRequest = {}
    moveRequest["Resources"] = {}
    table.insert(moveRequest["Resources"], studyId)
    moveRequest["Asynchronous"] = true
 
  local job = ParseJson(RestApiPost("/peers/remote_peer/store", DumpJson(moveRequest, true)))

end

Do I have to make any changes to my auto-routing script in order for it to use Transfers accelerator in P2P transfer?

P.S. This is my “Transfers” config on the local Orthanc server:

{

	"Transfers": {
		"Threads": 2, // Number of worker threads for one transfer
		"BucketSize": 4096, // Optimal size for a bucket (in KB)
		"CacheSize": 512, // Size of the memory cache to process DICOM files (in MB)
		"MaxPushTransactions": 4, // Maximum number of simultaneous receptions in push mode
		"MaxHttpRetries": 0, // Maximum number of HTTP retries for one bucket
		"PeerConnectivityTimeout": 1 // HTTP Timeout (in seconds) used when checking if a remote peer has the transfer plugin enabled in /transfers/peers GET route
	}
}

Any assistance on this is super appreciated!

Regards

Hi,
This is mine which is working in production

    local peer = "LongTermPeer"
    local resource = {}
    resource["Level"] = "Study"
    resource["ID"] = studyId
    local bodyP = {}
    bodyP["Resources"] = {}
    table.insert(bodyP["Resources"], resource)
    bodyP["Compression"] = "gzip"
    bodyP["Peer"] = peer
    bodyP["Priority"] = 10
    PrintRecursive(bodyP)
    RestApiPost('/transfers/send' , DumpJson(bodyP, false))

Thanks for this, Christophe,

I have a couple of questions,

  1. What does this mean? local peer = "LongTermPeer"and is this the equivalent to the remote peer?
  2. To send the scan to a specific peer, do I need to make the REST API call like this? RestApiPost('/transfers/send/remote_peer' , DumpJson(bodyP, false))
  3. Is there a specific reason to set a job priority explicitly?

Regards
Yash

  1. What does this mean? local peer = "LongTermPeer"and is this the equivalent to the remote peer?

Yes, it’s remote peer name

  1. To send the scan to a specific peer, do I need to make the REST API call like this? RestApiPost('/transfers/send/remote_peer' , DumpJson(bodyP, false))

No, That’s API url is not mentioned in Plugin’s document

  1. Is there a specific reason to set a job priority explicitly?

Read this first for more understanding about job. In fact, I have many jobs so that I set this job as the highest priority.