• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Using http retriever returns java.net.UnknownHostException:

    How-To
    2
    7
    2.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      radu.cigmaian
      last edited by

      Using http retriever returns java.net.UnknownHostException:

      1 Reply Last reply Reply Quote 0
      • R
        radu.cigmaian
        last edited by

        How can I get the nth match of a regexp usin http retriever?

        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by phildunlap

          Hi Radu,

          UnknownHostException - DNS failed to resolve hostname.

          1. Check hostname is typed correctly
          2. Check computer running Mango can access a gateway that does DNS (ping www.google.com, does it work?)
          3. Check that hostname is resolvable in your browser.

          Getting nth match
          You'll have to say more about this and possibly provide an example. Regex has the count braces {} so a expression like (?:.*?conditionText":(\d+).*?){5} would capture the fifth instance of the text conditionText":123 and from my testing captured only the fifth instance, so it is at value capture group 1, which would be only the number since the rest of the group is noncapturing (?:) but the (\d+) captures the value.

          Edit: Also, you may consider this if there are newlines: (?s)(?:.*?conditionText":(\d+).*?){5} as (?s) is the embedded flag to enable . to match newlines.

          1 Reply Last reply Reply Quote 0
          • R
            radu.cigmaian
            last edited by

            I fixed the unknown host issue, but the regexp is taking too long, I'm parsing the result of:
            https://api.apixu.com/v1/forecast.json?key=07cb1ff64c1e4186afa150737172404&q=Toronto&days=2
            and tring to get 50th value

            1 Reply Last reply Reply Quote 0
            • phildunlapP
              phildunlap
              last edited by

              Hmm. Well, I noticed there are only 49 temp_c values in that link, if that's related. Regex is pretty fast, but there probably does exist a more efficient expression if the goal is to get the last value for temp_c.

              R 1 Reply Last reply Reply Quote 0
              • R
                radu.cigmaian @phildunlap
                last edited by

                @phildunlap said in Using http retriever returns java.net.UnknownHostException::

                Hmm. Well, I noticed there are only 49 temp_c values in that link, if that's related. Regex is pretty fast, but there probably does exist a more efficient expression if the goal is to get the last value for temp_c.

                Actually the goal is to have a point showing each value. I've tried with this regexp and the cpu goes to 100%

                1 Reply Last reply Reply Quote 0
                • phildunlapP
                  phildunlap
                  last edited by

                  Hi Radu,

                  I gave it a shot. I did notice what you're saying if I put 50 in as the group number, but that regex doesn't match anyway. I found 48 got me the last value in the set using (?:.*?temp_c":(\d+[.]\d+).*?){48} 48 matched fairly quickly, and all lower numbers should match faster.

                  It sounds like you're getting each value into its own data point? You could also try something like grabbing the entire string into a regex (regex .* value index 0), and parsing it using a script like....

                  if(httpForecast.time > scriptRun.time) {
                      var forecast = JSON.parse(httpForecast.value);
                      for( var k = 0; k < forecast.forecast.forecastday.length; k+=1 ) {
                          var day = forecast.forecast.forecastday[k];
                          for( var i = 0; i < day.hour.length; i += 1 ) {
                               var hour = day.hour*;
                               forecastOutputPoint.set( hour.temp_c, DateTimeUtility.parseDate("yyyy-dd-MM HH:mm", hour.time, "America/Toronto") );
                          }
                      }
                      scriptRun.set(!scriptRun.value);
                  }
                  

                  Where forecastOutputPoint is a Numeric point log all data on the scripting data source, and scriptRun is a binary point on the scripting data source. If I didn't make any mistakes this should have all the values appear in forecastOutputPoint any time the http gets a new forecast and the script runs to parse it.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post