HISE Logo Forum
    • Categories
    • Register
    • Login

    How to debug Server.isOnline()

    Scheduled Pinned Locked Moved Scripting
    6 Posts 3 Posters 294 Views
    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.
    • Dan KorneffD
      Dan Korneff
      last edited by

      I'm using Server.isOnline() to check for an internet connection before I perform some networks tasks. It's implemented in a function like this:

      	// Check Internet Connection
      	function checkInternetConnection()
      	{
      		if(!Server.isOnline())
      		{
      			sendEvent(ErrorCode.NO_INTERNET);
      			return false;
      		}		
      		return true;
      	}
      

      This is returning false on some users systems even though they have internet.
      Server.isOnine() appears to just ping Google and Amazon as a test.

      bool ScriptingApi::Server::isOnline()
      {
      	const char* urlsToTry[] = { "http://google.com/generate_204", "https://amazon.com", nullptr };
      
      	for (const char** url = urlsToTry; *url != nullptr; ++url)
      	{
      		URL u(*url);
      
      		auto ms = Time::getMillisecondCounter();
      		std::unique_ptr<InputStream> in(u.createInputStream(false, nullptr, nullptr, String(), HISE_SCRIPT_SERVER_TIMEOUT, nullptr));
      		dynamic_cast<JavascriptProcessor*>(getScriptProcessor())->getScriptEngine()->extendTimeout(Time::getMillisecondCounter() - ms);
      
      		if (in != nullptr)
      			return true;
      	}
      
      	return false;
      }
      

      So I've had the end users perform this task manually via command prompt, and they get a response.

      curl -I http://google.com/generate_204
      returns:
      HTTP/1.1 204 No Content
      Content-Length: 0
      Cross-Origin-Resource-Policy: cross-origin
      Date: Wed, 03 Jan 2024 13:23:15 GMT
      
      and 
      ping -c 4 google.com
      returns:
      Pinging google.com [142.250.81.238] with 32 bytes of data:
      Reply from 142.250.81.238: bytes=32 time=13ms TTL=116
      Reply from 142.250.81.238: bytes=32 time=10ms TTL=116
      Reply from 142.250.81.238: bytes=32 time=10ms TTL=116
      Reply from 142.250.81.238: bytes=32 time=17ms TTL=116
      
      Ping statistics for 142.250.81.238:
          Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
      Approximate round trip times in milli-seconds:
          Minimum = 10ms, Maximum = 17ms, Average = 12ms
      

      It seems that they have an internet connection. What method can I use to gather information from the Server function to see where it's failing? Is there something similar to the Server Controller that can be tapped in to?

      Dan Korneff - Producer / Mixer / Audio Nerd

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @Dan Korneff
        last edited by

        @Dan-Korneff Are those users in China?

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        Dan KorneffD 1 Reply Last reply Reply Quote 0
        • Dan KorneffD
          Dan Korneff @d.healey
          last edited by

          @d-healey They are not in China. And the manual test shows that they can reach the isOnline endpoints. 馃し

          Dan Korneff - Producer / Mixer / Audio Nerd

          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Dan Korneff
            last edited by

            @Dan-Korneff Have you set a short timeout value? HISE_SCRIPT_SERVER_TIMEOUT=20000

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            Christoph HartC 1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart @d.healey
              last edited by

              What happens if you change the URL in the C++ code to use SSL:

              "https://google.com/generate_204"
              

              I know that sometimes on macOS there is an issue with connecting to non SSL domains.

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @Christoph Hart
                last edited by

                @Christoph-Hart said in How to debug Server.isOnline():

                I know that sometimes on macOS there is an issue with connecting to non SSL domains.

                That might be why I did this

                Link Preview Image
                Added custom plist entry to Mac exporter template by davidhealey 路 Pull Request #328 路 christophhart/HISE

                I noticed that the xcodeValidArchs for the plugin template is set to %ARM_ARCH% is that correct? Is it worth removing all of the IPP stuff from the MacOS exporters? Or are people still using it there?

                favicon

                GitHub (github.com)

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

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

                23

                Online

                1.7k

                Users

                11.8k

                Topics

                102.7k

                Posts