Unexpected error code with Tango REST API

Hi Igor,

I got some unexpected HTTP error codes while playing with the the REST API.
While reading the specification here, I am not very clear on the expected HTTP codes.
Perhaps it would deserve a dedicated section describing the error codes ?
Please find below the details.

Cheers,
Jerome



I get a "500 Internal Server Error" when getting an history on an attribute which is not polled (see below).
I would expect "503 Service Unavailable" in this case.


$ curl -v -u "tango-cs:tango" "https://mstatus.esrf.fr:443/tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/history" | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 –:–:– –:–:– –:–:–     0*   Trying 193.49.43.22…
* TCP_NODELAY set
* Connected to mstatus.esrf.fr (193.49.43.22) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.esrf.fr
* Server certificate: TERENA SSL CA 3
* Server certificate: DigiCert Assured ID Root CA
* Server auth using Basic with user 'tango-cs'
> GET /tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/history HTTP/1.1
> Host: mstatus.esrf.fr
> Authorization: Basic dGFuZ28tY3M6dGFuZ28=
> User-Agent: curl/7.51.0
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< Date: Tue, 02 May 2017 11:40:03 GMT
< Server: Apache-Coyote/1.1
< Cache-Control: private
< Expires: Thu, 01 Jan 1970 01:00:00 GMT
< Content-Type: application/json
< Connection: close
< Transfer-Encoding: chunked
< 
{ [4 bytes data]
* Curl_http_done: called premature == 0
100   236    0   236    0     0   1904      0 –:–:– –:–:– –:–:–  1918
* Closing connection 0
{
    "errors": [
        {
            "description": "State is not polled",
            "origin": "org.tango.server.servant.DeviceImpl.read_attribute_history_5(DeviceImpl.java:2607)",
            "reason": "API_AttrNotPolled",
            "severity": "ERR"
        }
    ],
    "quality": "FAILURE",
    "timestamp": 1493725203444
}


There is another error code issue when getting the event on the same attribute. Sometimes one get "503 Service Unavailable", sometimes "200 OK", with different error messages (see below).
I would expect "503 Service Unavailable" with error message "unknown:API_AttrNotPolled…" here.


$ curl -v -u "tango-cs:tango" "https://mstatus.esrf.fr:443/tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/change" 
*   Trying 193.49.43.22…
* TCP_NODELAY set
* Connected to mstatus.esrf.fr (193.49.43.22) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.esrf.fr
* Server certificate: TERENA SSL CA 3
* Server certificate: DigiCert Assured ID Root CA
* Server auth using Basic with user 'tango-cs'
> GET /tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/change HTTP/1.1
> Host: mstatus.esrf.fr
> Authorization: Basic dGFuZ28tY3M6dGFuZ28=
> User-Agent: curl/7.51.0
> Accept: */*
> 
< HTTP/1.1 503 Service Unavailable
< Date: Tue, 02 May 2017 14:00:32 GMT
< Server: Apache-Coyote/1.1
< Cache-Control: private
< Expires: Thu, 01 Jan 1970 01:00:00 GMT
< Content-Type: application/json
< Connection: close
< Transfer-Encoding: chunked
< 
* Curl_http_done: called premature == 0
* Closing connection 0
{"errors":[{"reason":"value has not been updated","description":"","severity":"","origin":"org.tango.rest.entities.Failures.createInstance(Failures.java:24)"}],"quality":"FAILURE","timestamp":1493733632375}
$


$ curl -v -u "tango-cs:tango" "https://mstatus.esrf.fr:443/tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/change" 
*   Trying 193.49.43.22…
* TCP_NODELAY set
* Connected to mstatus.esrf.fr (193.49.43.22) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.esrf.fr
* Server certificate: TERENA SSL CA 3
* Server certificate: DigiCert Assured ID Root CA
* Server auth using Basic with user 'tango-cs'
> GET /tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/change HTTP/1.1
> Host: mstatus.esrf.fr
> Authorization: Basic dGFuZ28tY3M6dGFuZ28=
> User-Agent: curl/7.51.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Tue, 02 May 2017 14:00:37 GMT
< Server: Apache-Coyote/1.1
< Cache-Control: private
< Expires: Thu, 01 Jan 1970 01:00:00 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< 
* Curl_http_done: called premature == 0
* Connection #0 to host mstatus.esrf.fr left intact
{"errors":[{"reason":"TangoProxyException","description":"unknown:API_AttrNotPolled[The polling (necessary to send events) for the attribute state is not started]","severity":"ERR","origin":"org.tango.client.ez.util.TangoUtils.convertDevFailedToException(TangoUtils.java:71)"}],"quality":"FAILURE","timestamp":1493733637490}
$
Hi Jerome,

500 http status seems fine - basically it progogates error from the Tango. Well it is not exactly internal server error but I do not know a better way to handle it.

503 is the result of fixing timeout issue - I have reduced default timeout to 3s, if there is no update from the upstream server REST server releases connection with 503 code.

So from the REST point of view these are valid situations it looks like ESRF restarted Facade so event configuration is gone.

Regards,
 
Register or login to create to post a reply.