ZeroMQ JSON Unicode Error

Hi all,

I followed your instructions at and the second option “ZeroMQ” worked for me.
I used the sample code on that page, but I got the following error:

File “zmq/backend/cython/socket.pyx”, line 617, in zmq.backend.cython.socket.Socket.send (zmq\backend\cython\socket.c:6625)
File “zmq/backend/cython/socket.pyx”, line 657, in zmq.backend.cython.socket.Socket.send (zmq\backend\cython\socket.c:6300)
TypeError: unicode not allowed, use send_string

My engine is English-Arabic, so I assume this issue has to do with the Arabic characters.

One more thing:

On the instruction page related to the first option 'Rest", this command is a bit confusing.

th tools/rest_translation_server.lua -model …/Recipes/baseline-1M-enfr/exp/model-baseline-1M-enfr_epoch13_3.44.t7 -gpuid 1 -host … -port -case_feature -bpe_model …

I understand that I should fill the … next to ‘host’ with the host, but what the port? Also, about -‘case_feature’ and 'bpe_model…"? How am I supposed to fill these blanks? Can you please provide a complete example with some notes?


Here’s my script for rest_translation_server.lua. You don’t need to specify the host if it’s on the same machine and you can specify any port number that isn’t used by some other process. Also you only use the phrase table option if there is a phrase table!
This server includes a tokenizer/detokenizer so you need to specify the options you used when tokenizing your data.
Good luck!

1 Like

Thanks Terence for your help! I will give it a try and see. Thanks a million!

I also look forward to hearing from OpenNMT team regarding the unicode error.

“TypeError: unicode not allowed, use send_string”


I’m use php

  1. Input preprocessing code:
    $source_txt= iconv('UTF-8', 'UTF-8//IGNORE', $source_txt);

  2. Output filter code
    $reply = iconv('UTF-8', 'UTF-8//IGNORE', $reply);
    $res_arr = json_decode($reply);
    $jserror = json_last_error();

1 Like

Thanks @netxiao for providing your PHP solution.