Extend time-out duration



  • @Christoph-Hart I have a long task with variable duration (server request). So sometimes I get an Execution timed-out error.

    How can I deal with it?
    Is it possible to extend the duration? (I've seen the extendTimeOutAPI is only for compile-time and has no influence on the compiled plugin)
    Does the error have an impact on the compiled plugin?



  • @Christoph-Hart Is there a way to make server request asynchronous?



  • You could give it a timer that checks every 500ms, but how do you do a server request?



  • @Christoph-Hart I used the juce url input stream
    It's not clear to me where/how to implement this timer...



  • Ah, so you've added a Scripting API call for that? In this case you will need to break the call up into something that calls the server and a scripting API call that checks the response, something like this:

    
    const var asyncCheck = Engine.createTimerObject();
    
    asyncCheck.setTimerCallback(function()
    {
        if(Server.gotSomeResponse())
        {
            // Do something
            this.stopTimer();
        }
    });
    
    Server.call("http://someaddress.");
    
    asyncCallback.startTimer(500);
    

    A more cleaner approach would be:

    function serverDoneCallback(obj)
    {
        Console.print(obj.status); // the status code (200 for OK)
        Console.print(obj.response); // the data 
    };
    
    Server.callWithCallback("http://myaddress.com", serverDoneCallback);
    

    But that requires some non-trivial wrapping on the C++ side...



  • @Christoph-Hart Oh great I see! At least for the first one, the second might be too high level for me at the moment 🙂
    Currently, I have one function that does the request and waits for the answer at once... Will try to split that...



  • @ustk What are you trying to achieve?


Log in to reply
 

6
Online

703
Users

2.8k
Topics

23.7k
Posts