LibreTranslation: API endpoint HTTP 500 error #257

Closed
opened 2022-11-07 12:04:49 +00:00 by nninja · 5 comments

Need some help getting LibreTranslation to work. Thanks!!

Error log:

Nov 07 22:52:22 akkoma mix[7106]: Request: GET /api/v1/akkoma/translation/languages
Nov 07 22:52:22 akkoma mix[7106]: ** (exit) an exception was raised:
Nov 07 22:52:22 akkoma mix[7106]:     ** (Cachex.ExecutionError) no function clause matching in Mint.HTTP1.close/1
Nov 07 22:52:22 akkoma mix[7106]:         (cachex 3.4.0) lib/cachex.ex:1405: Cachex.unwrap_unsafe/1
Nov 07 22:52:22 akkoma mix[7106]:         (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/akkoma_api/controllers/translation_controller.ex:25: Pleroma.Web.AkkomaAPI.TranslationController.languages/2
Nov 07 22:52:22 akkoma mix[7106]:         (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/akkoma_api/controllers/translation_controller.ex:1: Pleroma.Web.AkkomaAPI.TranslationController.action/2
Nov 07 22:52:22 akkoma mix[7106]:         (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/akkoma_api/controllers/translation_controller.ex:1: Pleroma.Web.AkkomaAPI.TranslationController.phoenix_controller_pipeline/2
Nov 07 22:52:22 akkoma mix[7106]:         (phoenix 1.6.11) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
Nov 07 22:52:22 akkoma mix[7106]:         (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.plug_builder_call/2
Nov 07 22:52:22 akkoma mix[7106]:         (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.call/2
Nov 07 22:52:22 akkoma mix[7106]:         (phoenix 1.6.11) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4

Tested LibreTranslation with curl - It's working:

$ curl http://192.168.1.13:5000/languages

[{"code":"en","name":"English"},{"code":"ar","name":"Arabic"},{"code":"az","name":"Azerbaijani"},{"code":"zh","name":"Chinese"},{"code":"cs","name":"Czech"},{"code":"da","name":"Danish"},{"code":"nl","name":"Dutch"},{"code":"eo","name":"Esperanto"},{"code":"fi","name":"Finnish"},{"code":"fr","name":"French"},{"code":"de","name":"German"},{"code":"el","name":"Greek"},{"code":"he","name":"Hebrew"},{"code":"hi","name":"Hindi"},{"code":"hu","name":"Hungarian"},{"code":"id","name":"Indonesian"},{"code":"ga","name":"Irish"},{"code":"it","name":"Italian"},{"code":"ja","name":"Japanese"},{"code":"ko","name":"Korean"},{"code":"fa","name":"Persian"},{"code":"pl","name":"Polish"},{"code":"pt","name":"Portuguese"},{"code":"ru","name":"Russian"},{"code":"sk","name":"Slovak"},{"code":"es","name":"Spanish"},{"code":"sv","name":"Swedish"},{"code":"tr","name":"Turkish"},{"code":"uk","name":"Ukranian"}]
$ curl -X POST -H "Content-type: application/json" -d '{
  "q": "Text to Translate",
  "source": "en",
  "target": "es",
  "api_key": "xxx-xxxx-xxxx-xxx-xxxxx"
}' 'http://192.168.1.13:5000/translate'

{"translatedText":"Texto para Traducir"}
Need some help getting LibreTranslation to work. Thanks!! Error log: ``` Nov 07 22:52:22 akkoma mix[7106]: Request: GET /api/v1/akkoma/translation/languages Nov 07 22:52:22 akkoma mix[7106]: ** (exit) an exception was raised: Nov 07 22:52:22 akkoma mix[7106]: ** (Cachex.ExecutionError) no function clause matching in Mint.HTTP1.close/1 Nov 07 22:52:22 akkoma mix[7106]: (cachex 3.4.0) lib/cachex.ex:1405: Cachex.unwrap_unsafe/1 Nov 07 22:52:22 akkoma mix[7106]: (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/akkoma_api/controllers/translation_controller.ex:25: Pleroma.Web.AkkomaAPI.TranslationController.languages/2 Nov 07 22:52:22 akkoma mix[7106]: (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/akkoma_api/controllers/translation_controller.ex:1: Pleroma.Web.AkkomaAPI.TranslationController.action/2 Nov 07 22:52:22 akkoma mix[7106]: (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/akkoma_api/controllers/translation_controller.ex:1: Pleroma.Web.AkkomaAPI.TranslationController.phoenix_controller_pipeline/2 Nov 07 22:52:22 akkoma mix[7106]: (phoenix 1.6.11) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2 Nov 07 22:52:22 akkoma mix[7106]: (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.plug_builder_call/2 Nov 07 22:52:22 akkoma mix[7106]: (pleroma 3.3.1-71-ge0032e47-develop) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.call/2 Nov 07 22:52:22 akkoma mix[7106]: (phoenix 1.6.11) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4 ``` Tested LibreTranslation with `curl` - It's working: ``` $ curl http://192.168.1.13:5000/languages [{"code":"en","name":"English"},{"code":"ar","name":"Arabic"},{"code":"az","name":"Azerbaijani"},{"code":"zh","name":"Chinese"},{"code":"cs","name":"Czech"},{"code":"da","name":"Danish"},{"code":"nl","name":"Dutch"},{"code":"eo","name":"Esperanto"},{"code":"fi","name":"Finnish"},{"code":"fr","name":"French"},{"code":"de","name":"German"},{"code":"el","name":"Greek"},{"code":"he","name":"Hebrew"},{"code":"hi","name":"Hindi"},{"code":"hu","name":"Hungarian"},{"code":"id","name":"Indonesian"},{"code":"ga","name":"Irish"},{"code":"it","name":"Italian"},{"code":"ja","name":"Japanese"},{"code":"ko","name":"Korean"},{"code":"fa","name":"Persian"},{"code":"pl","name":"Polish"},{"code":"pt","name":"Portuguese"},{"code":"ru","name":"Russian"},{"code":"sk","name":"Slovak"},{"code":"es","name":"Spanish"},{"code":"sv","name":"Swedish"},{"code":"tr","name":"Turkish"},{"code":"uk","name":"Ukranian"}] ``` ``` $ curl -X POST -H "Content-type: application/json" -d '{ "q": "Text to Translate", "source": "en", "target": "es", "api_key": "xxx-xxxx-xxxx-xxx-xxxxx" }' 'http://192.168.1.13:5000/translate' {"translatedText":"Texto para Traducir"} ```

interesting, the error log implies it's an issue with one of our dependecies

by any chance are you using a proxy?

i found an issue in the finch repo matching that description -> https://github.com/sneako/finch/pull/184

i've pushed a dependency update @ c0eecb55b

see if pulling the change, updating dependencies with MIX_ENV=prod mix deps.get and restarting, fixes your issue

interesting, the error log implies it's an issue with one of our dependecies by any chance are you using a proxy? i found an issue in the finch repo matching that description -> https://github.com/sneako/finch/pull/184 i've pushed a dependency update @ c0eecb55b see if pulling the change, updating dependencies with `MIX_ENV=prod mix deps.get` and restarting, fixes your issue
Author

Yes using a proxy indeed. The latest version has resolved the 500 error - Now becomes 400 timeout.

I reckon the request is now going through the HTTP proxy correctly, but couldn't reach my LibreTranslate instance (self-hosted on LAN)

So yeah, unclear on what's using the HTTP proxy, and what's not. Apparently Elasticsearch doesn't go through proxy.

Yes using a proxy indeed. The latest version has resolved the 500 error - Now becomes `400 timeout`. I reckon the request is now going through the HTTP proxy correctly, but couldn't reach my LibreTranslate instance (self-hosted on LAN) So yeah, unclear on what's using the HTTP proxy, and what's not. Apparently Elasticsearch doesn't go through proxy.

yeah indeed, elasticsearch uses a totally different HTTP Pool

i have some magic config for you, shove it in your prod.secret.exs

config :pleroma, :http,
  adapter: [
    pools: %{
      "http://yourlibretranslate.lan.domain" => [size: 10]
   }
  ]

this magic should make the specific URL prefix you put in the key bypass your proxy setting

yeah indeed, elasticsearch uses a totally different HTTP Pool i have some magic config for you, shove it in your `prod.secret.exs` ```elixir config :pleroma, :http, adapter: [ pools: %{ "http://yourlibretranslate.lan.domain" => [size: 10] } ] ``` this magic _should_ make the specific URL prefix you put in the key bypass your proxy setting
Author

I put a reverse proxy in front of LibreTranslate - It works!

Pleroma-FE doesn't seem to pick up the languages list (User settings > target lang option is still hidden) but all in all it works.

EDIT - Didn't see the latest reply

I put a reverse proxy in front of LibreTranslate - It works! Pleroma-FE doesn't seem to pick up the languages list (User settings > target lang option is still hidden) but all in all it works. EDIT - Didn't see the latest reply

closing this off, since language display was fixed over in AkkomaGang/pleroma-fe#196

closing this off, since language display was fixed over in https://akkoma.dev/AkkomaGang/pleroma-fe/issues/196
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#257
No description provided.