Server always returning empty list

Hi,

I start the server with the demo model from the website:

th tools/rest_translation_server.lua -model onmt_baseline_wmt15-all.en-de_epoch13_7.19_release.t7

But no matter what input I send, I always get back an empty list ([]) as a response:

curl -v -H "Content-Type: application/json" -d '{ "src" : "Hello World" }' http://127.0.0.1:7784/translator/translate

The HTTP code is 200 and the server doesn’t log any error messages either. The model itself seems to be okay, too, as th translate.lua with the same model gives useful results. This is under Ubuntu 16.04. Am I doing something wrong?

Regards
Daniel

Hi I need to modify the usage since it changed with the multi segment (batch) introduction

you need to do:
curl -v -H “Content-Type: application/json” -d ‘[{ “src” : “Hello World” }]’ http://127.0.0.1:7784/translator/translate

Thanks, that helps. Would be nice if someone could update http://opennmt.net/Advanced/#translation-rest-server.

Hi all,

I have a similar issue, but I think it’s not about syntax problem. When I execute translate.lua in my server I obtain results normally, but I don’t get same results using server/cliente architecture.

I can execute this without problems:

 `th translate.lua -model $DATA_ROOT/model_epochXXXX_release.t7 -replace_unk 1 -src input_text.txt`

I load the same model as server mode with no errors:

th tools/rest_translation_server.lua -model $DATA_ROOT/model_epochXXXX_release.t7 -replace_unk 1 -port 7777
...
...
[11/10/17 10:47:15 INFO] Launch server
Xavante started on port(s) 7777

But I have no results when I run my client command:

$ curl -v -H "Content-Type: application/json" -X POST -d '[{"src" : "hello world " }]' http://127.0.0.1:7777/translator/translate

  • About to connect() to 127.0.0.1 port 7777 (#0)
  • Trying 127.0.0.1…
  • Connected to 127.0.0.1 (127.0.0.1) port 7777 (#0)

POST /translator/translate HTTP/1.1
User-Agent: curl/7.29.0
Host: 127.0.0.1:7777
Accept: /
Content-Type: application/json
Content-Length: 27

  • upload completely sent off: 27 out of 27 bytes
    < HTTP/1.1 200 OK
    < Content-Type: application/json
    < Date: Fri, 10 Nov 2017 10:11:50 GMT
    < Server: RestServer
    < Content-Length: 2
    <
  • Connection #0 to host 127.0.0.1 left intact
    []

So I have empty array as result.
I’ve run the same code in other server, and it returns results properly.

How could I fix this issue?

Thanks in advance

line 14 of the rest_translation_server.lua file
change to:
local restserver = require(“tools.restserver.restserver”)

it will be fixed

Thanks for the response.

We’ve tried this solution, and it work perfectly!

Thank you!

The workaround was pushed on master. We have to investigate what is going on with the dependency.