• Resolved basselkordy

    (@basselkordy)


    Good evening

    I followed the instructions for integrating a custom translation API and used the Mock Translation API as a reference. I modified it to simply call a Python API i made. First, it submits a request to be processed, then it keeps polling on the request’s status until it’s finished. The Python API creates a Job for the translation request and puts it in a Redis task queue. currently it simply sleeps for 120 seconds, for testing purposes (not sure if that’s relevant). Here’s the modified plugin.

    The Python API takes quite some time to return results back. The problem is, before the API finishes processing the results, an error message comes up in the UI (see screenshot) saying “Blank response from server”, and in the debug console it says that a timeout occurred, and the error is coming from the file admin.js. I think it’s assumed somewhere that if the custom plugin doesn’t return a response within a certain time interval (i think 30 seconds), the application times out and gives the “Blank response” message.

    I looked around in Loco plugin’s source code to try to find any clues on where that timeout occurs, I’m just speculating here but i think it’s in pub/js/min/admin.js

    The thing is, this file is obfuscated, so I’m not really sure what I’m looking at.

    I’m pretty sure the timeout is not coming from the custom plugin’s end because even after i see the timeout error on the console, i keep seeing that the API is being calling by translator.php.

    I tried my best, being neither an expert in PHP nor WordPress. please advise. thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Tim W

    (@timwhitlock)

    Firstly, thanks for your interest in trying a custom API integration. You are the first person to ever ask me about it.

    If your script takes a long time to complete, then you’ll either have to configure your server to wait longer, or ensure your API job completes more quickly. My code (admin.js etc..) will wait forever for a response.

    Neither WordPress, nor my plugin enforce timeouts. This is dictated by your PHP runtime, and server set up. That topic is outside the scope of my plugin support, but have a look at the max_execution_time directive. Also be aware that (depending on your web server) fast cgi processes also have timeouts. Make sure your PHP and server logging is set up properly so you’ll know for sure what is timing out. If your script sleeps for 120 seconds, this is almost certainly the culprit.

    Aside: I think the sw.js timeout in your console is a separate request. I don’t know this file, but Loco Translate sends its requests directly through the jQuery Ajax functions.

Viewing 1 replies (of 1 total)

The topic ‘Timeout issue when integrating custom translation API’ is closed to new replies.