2 Replies Latest reply on Sep 13, 2016 2:26 PM by markus@tembosocial.com

    Is there a way to set osapi.http request timeout settings / parameters

    markus@tembosocial.com

      Hi everyone,

       

      I have searched the developer forum and found a couple of people facing the same issue, either with osapi.http.get or osapi.http.post, but none have been answered so far, so trying to get some attention here as it might help not only me but others as well.

       

      As best practises advise, we are calling our backend servers from Tiles or Apps inside Jive via osapi.http.* - which is nicely proxied through Jive, allows for signing the requests so we can ensure their authenticity on our servers, etc, etc. All good stuff.

       

      BUT - here's the problem: In some, rare cases (with complex data relationships to be processed) one of our endpoints takes some time to respond - which is not a problem for the user, as the app does that "in the background" and is still responsive.

      However, the Jive server is comparatively impatient and returns a "504" - Gateway Timeout in the response object instead of waiting for our server to respond (which it does, but too late as the osapi.http.* already came back with a 504).

       

      1) As a short term workaround for our clients: Is there a server setting to extend the timeout period for osapi.http.* requests? With a simple test endpoint, I found that it seems to time out at 13 seconds.

       

      2) I found no solution to change that in the request: The readTimeout parameter that seems to work with the JiveConnects API isn't working in osapi.http.* - which would be an ideal solution (I suppose that's why it was implemented for Jive Connects). Trying the keep-alive header didn't help either (although it is being passed to the endpoint server).

       

      Simple script I tested with:

       

      osapi.http.get({

         'href': 'http://j232626.servers.jiffybox.net/endpoints/jsonnowait.php' ,

         'noCache': true,

         'readTimeout':30,

         'headers' : { 'Connection' : [ 'keep-alive' ] }

      }).execute(function( response ) {

      console.log(response);

      });

      as a positive test works (of course).

       

      osapi.http.get({

         'href': 'http://j232626.servers.jiffybox.net/endpoints/jsonwait.php' ,

         'noCache': true,

         'readTimeout':30,

         'headers' : { 'Connection' : [ 'keep-alive' ] }

      }).execute(function( response ) {

      console.log(response);

      });

       

      returns a 504 if the server waits for longer than 12 seconds on a plain vanilla dev instance (added a simple sleep(); in that also very simple testing php script).

       

       

      Pinging Ryan Rutan, but also Rashed Talukder, Yuval Twig as you have been mentioned on the other threads regarding the same issue.

       

      cc'ing Butch Marshall, Elysha Ames, Brennan Kirby

       

      Thanks!

       

       

      Related discussions:

      Download a file via jive (not from a direct url)?

      How do you set request timeout header in osapi?

      Access add-on back-end endpoints from Jive App