REST-API, php C-ECHO

425 views
Skip to first unread message

dicom.o...@gmail.com

unread,
Jul 30, 2017, 11:29:35 AM7/30/17
to Orthanc Users
Hello!
Please, help me to understand how to make POST "../modalities/remote_server/echo" via cURL in php, to get status 200 ( OK ) from the remote dicom-modality.

Thanks a lot!

Thibault Nélis

unread,
Jul 31, 2017, 5:17:15 AM7/31/17
to orthan...@googlegroups.com
As you mentioned, the HTTP API contract of Orthanc for this
functionality is simply "POST to the resource, and watch for the status
code" (no content, no particular headers to set).

This mailing list focuses on the Orthanc server, for help on how to
perform this request with PHP and its libcurl bindings refer to:

https://secure.php.net/support.php
https://secure.php.net/manual/en/book.curl.php
--
Thibault Nélis <t...@osimis.io>
Osimis

arch....@gmail.com

unread,
Aug 13, 2017, 12:22:46 AM8/13/17
to Orthanc Users
понедельник, 31 июля 2017 г., 14:17:15 UTC+5 пользователь Thibault Nélis написал:
i try'd with shell command:
$ curl --verbose -X POST http://localhost:8042/modalities/LOCAL/echo -d "{}"
* About to connect() to localhost port 8042 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8042 (#0)
> POST /modalities/LOCAL/echo HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8042
> Accept: */*
> Content-Length: 2
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 2 out of 2 bytes

and it stucks here.
thats why my request from php not working.
i dont know why. i have 2 Orthanc servers with the same thing.
All other requests is working well.

Thibault Nélis

unread,
Aug 14, 2017, 4:18:03 AM8/14/17
to orthan...@googlegroups.com
On Sat, 2017-08-12 at 21:22 -0700, arch....@gmail.com wrote:
> i try'd with shell command:
> $ curl --verbose -X POST http://localhost:8042/modalities/LOCAL/echo
> -d "{}"
> * About to connect() to localhost port 8042 (#0)
> *   Trying 127.0.0.1...
> * Connected to localhost (127.0.0.1) port 8042 (#0)
> >
> > POST /modalities/LOCAL/echo HTTP/1.1
> > User-Agent: curl/7.29.0
> > Host: localhost:8042
> > Accept: */*
> > Content-Length: 2
> > Content-Type: application/x-www-form-urlencoded
> >
> * upload completely sent off: 2 out of 2 bytes
>
> and it stucks here. 
> thats why my request from php not working.
> i dont know why. i have 2 Orthanc servers with the same thing.
> All other requests is working well.

Hmm definitely check the Orthanc logs, maybe start it in verbose or
trace mode if you don't see much.

I attach a session where I show the feature working. If you have a
Docker engine lying around you may try to reproduce it exactly[1].
(Note that you didn't need to send '{}' in the body of the HTTP
request, but I tried it anyway and Orthanc just ignores the body and it
thus works fine also.)

If the problem persists between two local instances it can get pretty
interesting. If not, then you'll want to check any and all gateways
between the devices, see if one doesn't block that request for whatever
reason (a tool like Wireshark should give you all the information you
need).

[1] https://bitbucket.org/osimis/orthanc-setup-samples/src/d1e0017863db
d520b63092ad5da05bad05e4c15d/docker/dicom-association/?at=master
echo-test

Sébastien Jodogne

unread,
Aug 25, 2017, 11:00:57 AM8/25/17
to Orthanc Users, arch....@gmail.com
Hello,

Here is my configuration file of Orthanc:

 {
  "DicomModalities" : {
    "LOCAL" : [ "STORESCP", "127.0.0.1", 2000 ]
  }
}

Here is what happen if no DICOM server is running on the 2000 port of the localhost (the HTTP status returned by curl is "500 Internal Server Error"):

{
   "HttpError" : "Internal Server Error",
   "HttpStatus" : 500,
   "Message" : "Error in the network protocol",
   "Method" : "POST",
   "OrthancError" : "Error in the network protocol",
   "OrthancStatus" : 9,
   "Uri" : "/modalities/LOCAL/echo"
}

But, if I start a "storescp" server on my localhost (using the "storescp 2000" command line), the call succeeds (the HTTP status returned by curl is "200 OK"):



On Sunday, August 13, 2017 at 6:22:46 AM UTC+2, arch....@gmail.com wrote:
i try'd with shell command: 
$ curl --verbose -X POST http://localhost:8042/modalities/LOCAL/echo -d "{}" 
[...]
* upload completely sent off: 2 out of 2 bytes 

and it stucks here.

If Orthanc gets stuck, this means that it cannot reach the remote "LOCAL" modality and is waiting until a timeout, most probably because of firewall restrictions.

Before developing on the top of the REST API, make sure to test your network infrastructure using the "Test Echo" button of Orthanc Explorer works properly in the "Query/Retrieve" tab:

HTH,
Sébastien-

arch....@gmail.com

unread,
Sep 24, 2017, 8:02:24 PM9/24/17
to Orthanc Users
пятница, 25 августа 2017 г., 20:00:57 UTC+5 пользователь Sébastien Jodogne написал:
After rebuilding with --DUSE_SYSTEM_DCMTK = OFF problem is gone. i dont know what was that.
Reply all
Reply to author
Forward
0 new messages