REST API installation on Windows

Hello tangoer.

I want to use tango REST API to access device (WEB and REST are new to me).

My environment: Windows10, libtango_9.3.4_v141_x64, Java11(11.0.12), rest-server-2.2(download from https://github.com/hereon-wpi/rest-server), waltz-1.0.10, TANGO_HOST=localhost:10000

Based on https://github.com/tango-controls/rest-server/wiki and https://waltz-docs.readthedocs.io/en/latest/installation_guide/ (some information is outdated?), i test rest-server-2.2 on windows 10 as:

1. copy tango.war (rest-server-2.2) into %CATALINA_HOME%\webapps directory
2. start tomcat: startup.bat

Firstly i test with tomcat-10.0.10, tango.war can't start! then test with tomcat-9.0.52, tango.war start successfully, but after access http://localhost:8080/tango/rest/v11/hosts/localhost/devices, http://localhost:8080/tango/rest/v11/hosts/localhost;port=10000/devices/sys/tg_test/1/attributes, etc. when exit tomcat there is a memory leak error, last i test with tomcat-8.5.69, the result is same with tomcat-9.0.52.

1. Whether i missed some configuration?
2. TangoDatabase's create_db.sql script file created a device named sys/rest/0 (TangoRestServer/rest) in tango database, when use rest-server-2.2, if we need to configure this device's property (as for rest-server-1.x.jar)? or if we need to config and start rest-server-1.x.jar?

Lastly, i copy waltz.war(1.0.10) into %CATALINA_HOME%\webapps/ directory, start tomcat9, waltz start successfully, Open browser and go to http://localhost:8080/waltz, but it waiting response forever, nothing displayed in browser.
Edited 4 weeks ago
Hi Jimmy,

Thank for giving a try to rest-server and waltz!

Based on https://github.com/tango-controls/rest-server/wiki and https://waltz-docs.readthedocs.io/en/latest/installation_guide/ (some information is outdated?),

Yeah, the documentation is a bit outdated. if you can contribute an update that would be awesome! There is also a tutorial in the Tango docs related to your topic - here

Firstly i test with tomcat-10.0.10, tango.war can't start! then test with tomcat-9.0.52, tango.war start successfully, but after access http://localhost:8080/tango/rest/v11/hosts/localhost/devices, http://localhost:8080/tango/rest/v11/hosts/localhost;port=10000/devices/sys/tg_test/1/attributes, etc. when exit tomcat there is a memory leak error, last i test with tomcat-8.5.69, the result is same with tomcat-9.0.52.

Do you get any meaningful response in this case e.g. list of attributes? If so then the rest is ok.

1. Whether i missed some configuration?

The only thing I can think of - setting up tomcat users and roles as described here

2. TangoDatabase's create_db.sql script file created a device named sys/rest/0 (TangoRestServer/rest) in tango database, when use rest-server-2.2, if we need to configure this device's property (as for rest-server-1.x.jar)? or if we need to config and start rest-server-1.x.jar?

TangoRestServer tango server is deprecated since 2.0. Since then it is only a web application and does not require any Tango environment. So just ignore it.

Lastly, i copy waltz.war(1.0.10) into %CATALINA_HOME%\webapps/ directory, start tomcat9, waltz start successfully, Open browser and go to http://localhost:8080/waltz, but it waiting response forever, nothing displayed in browser.

That probably means something is wrong on the tomcat side. If you do not get any response most probably due to the tomcat does not accept any requests. Do you deploy both apps into a single tomcat instance? Are there any errors in the logs?

Hope this helps.

Cheers,
Hi Ingvord, thanks

I had attached a tomcat's log file on my first post, as for debug i provide some one information as follow:

C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest
{"v10":"http://localhost:8080/tango/rest/v10","v11":"http://localhost:8080/tango/rest/v11"}
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/
[{"name":"dserver/DataBaseds/2","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/dserver/DataBaseds/2"},{"name":"dserver/TangoAccessControl/1","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/dserver/TangoAccessControl/1"},{"name":"dserver/TangoRestServer/rest","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/dserver/TangoRestServer/rest"},{"name":"dserver/TangoTest/test","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/dserver/TangoTest/test"},{"name":"sys/access_control/1","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/sys/access_control/1"},{"name":"sys/database/2","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/sys/database/2"},{"name":"sys/rest/0","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/sys/rest/0"},{"name":"sys/tg_test/1","href":"http://localhost:8080/tango/rest/v10/hosts/localhost;port=10000/devices/sys/tg_test/1"}]
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/
{"id":"localhost:10000/sys/tg_test/1","name":"sys/tg_test/1","host":"localhost:10000","info":{"name":"sys/tg_test/1","ior":"IOR:010000001700000049444c3a54616e676f2f4465766963655f353a312e300000010000000000000060000000010102000a0000003132372e302e302e3100e3e10e000000fe5db81b61000022b0000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100","version":"5","exported":true,"pid":8880,"server":"TangoTest/test","hostname":"desktop-rheknrh","classname":"unknown","is_taco":false,"last_exported":"17th August 2021 at 21:23:41","last_unexported":"17th August 2021 at 09:04:02"},"attributes":"http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1//attributes","commands":"http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1//commands","pipes":"http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1//pipes","properties":"http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1//properties","state":"http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1//state"}
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/
{"id":"localhost:10000/sys/tg_test/1/double_scalar","name":"double_scalar","device":"sys/tg_test/1","host":"localhost:10000","info":{"name":"double_scalar","writable":"READ_WRITE","data_format":"SCALAR","data_type":"DevDouble","max_dim_x":1,"max_dim_y":0,"description":"No description","label":"double_scalar","unit":"","standard_unit":"No standard unit","display_unit":"No display unit","format":"%6.2f","min_value":"Not specified","max_value":"Not specified","min_alarm":"Not specified","max_alarm":"Not specified","writable_attr_name":"double_scalar","level":"OPERATOR","extensions":[],"alarms":{"min_alarm":"Not specified","max_alarm":"Not specified","min_warning":"Not specified","max_warning":"Not specified","delta_t":"Not specified","delta_val":"Not specified","extensions":[],"tangoObj":{"min_alarm":"Not specified","max_alarm":"Not specified","min_warning":"Not specified","max_warning":"Not specified","delta_t":"Not specified","delta_val":"Not specified","extensions":[]}},"events":{"ch_event":{"rel_change":"Not specified","abs_change":"Not specified","extensions":[],"tangoObj":{"rel_change":"Not specified","abs_change":"Not specified","extensions":[]}},"per_event":{"period":"1000","extensions":[],"tangoObj":{"period":"1000","extensions":[]}},"arch_event":{"rel_change":"Not specified","abs_change":"Not specified","period":"Not specified","extensions":[],"tangoObj":{"rel_change":"Not specified","abs_change":"Not specified","period":"Not specified","extensions":[]}},"tangoObj":{"ch_event":{"rel_change":"Not specified","abs_change":"Not specified","extensions":[]},"per_event":{"period":"1000","extensions":[]},"arch_event":{"rel_change":"Not specified","abs_change":"Not specified","period":"Not specified","extensions":[]}}},"extensions":[],"sys_extensions":[],"isMemorized":false,"isSetAtInit":true,"memorized":"NOT_MEMORIZED","root_attr_name":"Not specified","enum_label":[]},"value":"http://localhost:8080/tango/rest/v11/hosts/localhost;port=10000/devices/sys/tg_test/1/attributes/double_scalar/value","properties":"http://localhost:8080/tango/rest/v11/hosts/localhost;port=10000/devices/sys/tg_test/1/attributes/double_scalar/properties","history":"http://localhost:8080/tango/rest/v11/hosts/localhost;port=10000/devices/sys/tg_test/1/attributes/double_scalar/history"}
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value

C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value

C:\Users\ICS>

http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value not return any data, at same time tomcat cosole output:

WARN [http-nio-8080-exec-1] org.jboss.resteasy.core.registry.SegmentNode.match RESTEASY002142: Multiple resource methods match request "GET /rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value". Selecting one. Matching methods: [public org.tango.rest.v10.JaxRsDeviceAttribute$ImageAttributeValue org.tango.rest.v10.JaxRsDeviceAttribute.deviceAttributeGetValueImage() throws java.lang.Exception, public java.lang.Object org.tango.rest.v10.JaxRsDeviceAttribute.deviceAttributeGetValuePlain() throws java.lang.Exception, public org.tango.rest.v10.entities.AttributeValue org.tango.rest.v10.JaxRsDeviceAttribute.deviceAttributeValueGet() throws fr.esrf.Tango.DevFailed]


stop and restart tomcat, then:

C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value
-100.02646367483833
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value
-104.12387729298892
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value
-108.18957382302479
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value
{"name":"double_scalar","host":"localhost:10000","device":"sys/tg_test/1","value":-204.45016137046377,"quality":"ATTR_VALID","timestamp":1629208730662}
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value
{"name":"double_scalar","host":"localhost:10000","device":"sys/tg_test/1","value":-228.09725384486381,"quality":"ATTR_VALID","timestamp":1629208750736}
C:\Users\ICS>curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value
{"name":"double_scalar","host":"localhost:10000","device":"sys/tg_test/1","value":-232.01440271492828,"quality":"ATTR_VALID","timestamp":1629208754137}


The output is every strange, same repeated command's return data element may different!!! tomcat cosole output the same WARN message as above!

I have another question: is tango.war or waltz.war must configure a TangoAccessControl device for it?

I'll check my tomcat configuration to find the problem! thanks for your help.
Edited 4 weeks ago
Hi.

I had successfully deloyed tango REST API and waltz, it's great, thanks to developer(s).

After browse the waltz source code, i find that my first failure of access waltz is that my computer not connect to internet!

Only one remaining problems:curl -u "tango-cs:tango" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value will cause the rest server throw an exception!
Hi Jimmy,

I would recommend to deliberately pass required response type using request headers, e.g.


curl -u "tango-cs:tango" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8080/tango/rest/v11/hosts/localhost/devices/sys/tg_test/1/attributes/double_scalar/value


Please find out more here: link
 
Register or login to create to post a reply.