7 Replies Latest reply on Apr 10, 2014 6:13 AM by Brandt Wijbenga

    Using Rho::Network.responseTimeout

    Brandt Wijbenga

      Hi,

      Our app is communicating with a webservice via both synchronous and asynchronous calls. Since we want the synchronous calls to return quickly (as we don't want to give the user the impression of a 'frozen' app) we are attempting to regulate the timeout using the Rho::Network.responseTimeout using something like the following:

       

      if ( async )
        Rho::Network.responseTimeout = async_timeout
        Rho::Network.post( http_params, callbackUrl )
      else  
        Rho::Network.responseTimeout = sync_timeout
        result = Rho::Network.post( http_params, callbackUrl )
        callback.call( result[ :success ], ... )
      end
      

       

      However, we found that this is not working as we expected. It looks like the timeout value that is used, is the value from BEFORE setting the responseTimeout value.

      Our observations:

      - rhoconfig.txt defines a 'net_timeout = 180.'

      - the responseTimeout is set to 15 seconds.

      - the actual timeout from the following network post is 180 seconds

      - the responseTimeout is set to 60 seconds

      - the actual timeout from the following network post is now 15 seconds

      ..and so on.

      Is this a bug, or are we using this incorrectly? Any insight on this would be appreciated.

        • Re: Using Rho::Network.responseTimeout
          Kutir Mobility

          Hi Brandt,

          If I am right, the value you set for  Rho::Network.responseTimeout will overwrite the "rhoconfig.txt net_timeout".

          I see you already aware that Rho::Network.responseTimeout is a global variable.

           

          We are not able to understand your observations fully. Can you explain what issue you are facing bit more detailed please.

           

          Visnupriya R

          Kutir Mobility

            • Re: Re: Using Rho::Network.responseTimeout
              Brandt Wijbenga

              Hi,

               

              I understood that the timeout value from rhoconfig will be overruled by setting the responseTimeout value. I included it here because it seems to explain the first timeout value we are observing.

               

              As for more details, consider the following pseudocode:

              Rho::Network.responseTimeout = value1
              Rho::Network.post call 1
              Rho::Network.responseTimeout = value2
              Rho::Network.post call 2
              

              Our experience:

              • Call 1 uses an actual timeout value from the rhoconfig file.
              • Call 2 uses an actual timeout value of value1, even though it was just set to value2.

              And so on.

               

              The problem is that a call using Rho::Network.post seems to be using the previous value of the timeout, instead of the current value.

                • Re: Using Rho::Network.responseTimeout
                  Kutir Mobility

                  Brandt,

                  I tried a quick app here.

                  For me its works fine.

                  Before set, It prints net_timeout value from rhoconfig,txt

                  after set Rho::Network.responseTimeout = 15, it prints as 15

                  Could you please share the steps to reproduce your bug ?

                   

                  Visnupriya R

                  Kutir Mobility

                    • Re: Re: Using Rho::Network.responseTimeout
                      Brandt Wijbenga

                      Hi

                       

                      I can confirm that it prints out the correct responseTimeout value. However, it is not using that value.

                       

                      I modify the code to this:

                       

                      Rho::Network.responseTimeout = options[ :timeouts ][ :async ]
                      puts '====='
                      puts 'Doing an asynchronous Rho::Network.post with parameters:'
                      puts ' http_params=' + http_params.to_s
                      puts 'Current value of Rho::Network.responseTimeout=' + Rho::Network.responseTimeout.to_s 
                      Rho::Network.post( http_params, callbackUrl )
                      

                      I am running my webservice in debug mode and I have set it to wait in a break point so any operations attempted will time out.

                      Now when I start up the application, it will add some scheduled downloads to process in the background.

                      The log outputs this:

                      I 03/18/2014 16:14:16:424 00001a14                  APP| RHO serve: /app/Synchronization/add_scheduled_items
                      I 03/18/2014 16:14:16:470 00001a14                  APP| Params: {"rho_callback"=>"1"}
                      I 03/18/2014 16:14:16:520 00001a14      Synchronization| Added scheduled 'BiDownloadAppointments'
                      I 03/18/2014 16:14:16:585 00001a14      Synchronization| Added scheduled 'BiDownloadPlanning'
                      I 03/18/2014 16:14:17:210 00001a14                  APP| RHO serve: /app/Synchronization/send_buffer_item
                      I 03/18/2014 16:14:17:210 00001a14                  APP| Params: {"rho_callback"=>"1"}
                      I 03/18/2014 16:14:17:225 00001a14              Network| NetworkC hasNetwork+
                      I 03/18/2014 16:14:17:280 00001a14      Synchronization| Executing 'BiDownloadAppointments'
                      I 03/18/2014 16:14:17:280 00001a14                  APP| =====
                      I 03/18/2014 16:14:17:295 00001a14                  APP| Doing an asynchronous Rho::Network.post with parameters:
                      I 03/18/2014 16:14:17:311 00001a14                  APP|  http_params={:url=>"http://172.16.100.86/ConnectItSe2_8/MobileClient1.asmx/GetAppointments", :verifyPeerCertificate=>false, :authType=>:basic, [..], :headers=>{"Content-Type"=>"application/json", "DeviceId"=>"c718410d-e570-aba5-23f3-aa9efa0f3e62",[..]}, :body=>"{\"request\":{\"known_ids\":[48196,48198],\"last_update\":\"\\/Date(1395155347000)\\/\"}}"}
                      I 03/18/2014 16:14:17:327 00001a14                  APP|  callbackUrl=/app/Helpers/webservice_callback?callback_id=0
                      I 03/18/2014 16:14:17:329 00001a14                  APP| Current value of Rho::Network.responseTimeout=12
                      I 03/18/2014 16:14:17:329 00001a14              Network| addCommand: 
                      I 03/18/2014 16:14:17:329 00001654              Network| Starting main routine...
                      I 03/18/2014 16:14:17:363 00001654                  Net| Method: POST;Url: http://172.16.100.86/ConnectItSe2_8/MobileClient1.asmx/GetAppointments
                      <snip>
                      I 03/18/2014 16:17:17:162 00001a14              Network| NetworkC hasNetwork+
                      E 03/18/2014 16:17:17:915 00001654                  Net| Call HttpSendRequest failed. Url:http://172.16.100.86/ConnectItSe2_8/MobileClient1.asmx/GetAppointments. With code : 12002.Message: Er heeft een time-out van de bewerking plaatsgevonden.
                      I 03/18/2014 16:17:17:928 00001654                  Net| Method: POST;Url: http://127.0.0.1:52325/app/Helpers/webservice_callback?callback_id=0
                      I 03/18/2014 16:17:17:951 00001a14           HttpServer| Process URI: '/app/Helpers/webservice_callback'
                      I 03/18/2014 16:17:17:960 00001a14                  APP| RHO serve: /app/Helpers/webservice_callback
                      I 03/18/2014 16:17:17:982 00001a14              RhoRuby| require_compiled: Helpers/helpers_controller
                      I 03/18/2014 16:17:17:994 00001a14                  APP| Params: {"callback_id"=>"0", "__rho_object"=>{"__rho_inline"=>"0"}, "rho_callback"=>"1"}
                      E 03/18/2014 16:17:18:044 00001a14           BufferItem| Execution of buffer item 'BiDownloadAppointments' failed 1 times.
                      

                      As you can see from the timestamps, even though it logs a response timeout of 12 seconds, it is actually 180 seconds (the initial rhoconfig value).

                       

                      Subsequent calls seem to exhibit the same behaviour.

                      • Re: Using Rho::Network.responseTimeout
                        Brandt Wijbenga

                        Did you have any chance to look into this yet?

                         

                        Regards