4 Replies Latest reply on Jan 6, 2015 8:39 AM by Jon Tara

    Rho Network API not working

    Siddhant  Wadhera

      Hi

       

      In my application i need to make  few calls to server.As the app is a hybrid app i am using Rho Network API Java script Usage in order to make the POST request.

      Below is the code

      var loginProps = {

                      url : "https://test.server.com",

                      headers : {

                          "Content-Type" : "application/json",

                         },

                      body : {"user" : "sid"}

                  }

       

                  console.log(loginProps);

                  var response  = Rho.Network.post(loginProps);

       

                  console.log(response['body']);

       

      Strangely the connection to the server itself is not being made as i get the Error_code = 1 and  http request failed with code 12029.

       

      Below are the logs  :

      E 12/31/2014 07:17:41:282 000013f0                  Net| Call HttpSendRequest failed. Url:https://test.server.com.

       

      With code : 12029.Message: A connection with the server could not be established


      I am not able to understand what might be the reason for this ??

       

      Is there any proxy settings i have to set??

       

      Looking forward to a solution

       

      Thanks

      Siddhant

        • Re: Rho Network API not working
          Jon Tara

          Can you access your server from a web  browser on your device?

           

          Unrelated to your problem, but I certainly would not use a synchronous Network request, especially in Javascript! The browser will be frozen until a response if received, and no user interaction is possible. Always use asynchronous Network calls.

           

          And I would encourage you to use Ruby for Network.

            • Re: Rho Network API not working
              Siddhant  Wadhera

              Hi Jon

              Thanks for the quick reply

              Yes i am able to access  the server from a browser using POST man Client app on chrome.

               

              But when i try the same from Rho Simulator i get the error as mentioned in my earlier post.

              What could be the possible reason for this??

               

              Is there any particular reason for using the RUBY for Network??

               

              PS : The above code is just for testing i will be using the Asynchronous calls only.This was just a way to test the Java Script usage of Network API.

               

              Thanks

              Siddhant

                • Re: Rho Network API not working
                  Jon Tara
                  Is there any particular reason for using the RUBY for Network??

                   

                  Writing network code - or, really, anything other than UI code - e.g. controller, model, etc. - in Javascript just adds an unnecessary layer of complexity and delay. It's a handy capability if you do not want to learn Ruby, but IMO it just slows things down and is a completely unnecessary complication. The Javascript code just proxies to the underlying Ruby code.

                   

                  Javascript is NOT simply an "alternative programming language" in Rhodes. Javascript code runs within the webview control and is subject to many limitations and inefficiencies vs. the Ruby code running in the main native app.

                   

                  Javascript runs quite slowly compared to Ruby on most of the supported platforms. iOS is particularly inhibited, because Javascript runs in a "penalty box" in the UIWebView, unable to take advantage of just-in-time compilation that is available to the system web browser. (Web browser can use it, UIWebView cannot.) While iOS8 removes this restriction, Rhodes does not yet use the new WKWebView that removes this roadblock. UIWebView still has a "penalty box".

                   

                  I would love to see Rhodes updated to use WKWebView if running on iOS 8 or higher.

                  • Re: Rho Network API not working
                    Jon Tara

                    Oh, you are testing on RhoSimulator? I was assuming you were testing on a real device - that's where connectivity issues usually occur.

                     

                    Make sure, then, that your desktop that you are running RhoSimulator on has access to your server. Test basic connectivity first.