Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Register
    • Login

    NETWORK_CONNECTTIMEOUT with SSL

    Scheduled Pinned Locked Moved Cinema 4D SDK
    2024c++20252026
    5 Posts 2 Posters 22 Views 2 Watching
    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 Offline
      Rox
      last edited by ferdinand

      Hello,

      Trying to extend the network connect timeout, following this example:

        // This example retrieve the result from a POST and print it.
       
        maxon::Url theServer { "http://localhost:8080"_s };
       
        // Prepares the data that will be post
        maxon::String postData = "foo=bar&bin=go"_s;
       
        theServer.Set(maxon::URLFLAGS::HTTP_POSTMETHOD, maxon::HTTPMETHOD::POST) iferr_return;
        theServer.Set(maxon::URLFLAGS::HTTP_POSTDATA, maxon::CString(postData, maxon::StringEncodings::Utf8())) iferr_return;
       
        maxon::BaseArray<maxon::Char> memReq;
       
        // Retrieves the answer and read it to memory
        iferr (maxon::FileUtilities::ReadFileToMemory(theServer, memReq))
          DiagnosticOutput("@", err);
       
        // Prints the answer from server
        ApplicationOutput("answer @", memReq);
       
        // Prints the answer as a string
        maxon::String result(memReq);
        ApplicationOutput("result @", result);
      

      Using the following works well on http localHost, but does not work with SSL (web https):

       theServer.Set(maxon::URLFLAGS::NETWORK_CONNECTTIMEOUT, maxon::Milliseconds(15 * 1000)) iferr_return;  // allow 15 seconds before timeout
              theServer.Set(maxon::URLFLAGS::NETWORK_SESSIONTIMEOUT, maxon::Milliseconds(15 * 1000)) iferr_return;
      

      How can we force the timeout extension when using SSL ? Currently it defaults to around 10 seconds. Also, for SSL, do we need to do anything other than setting the flags ?

      Thanks.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF Offline
        ferdinand @Rox
        last edited by ferdinand

        Hey @Rox,

        Thank you for reaching out to us. Please provide a concrete executable code example as to what exactly does not work with SSL. I understand that you have put effort into make yourself understood, but in the current form it is very ambiguous what it not working for you.

        HTTPS methods surely work, we use them heavily internally, in all variants such as GET, POST, DELETE, etc. I looked at our code base and did not find an exact match for POSTing towards an HTTPs endpoint with a custom timeout, but found one for DELETEing.

        You can connect to an https URL without any extra steps. I am not quite sure what you would consider "setting the flags" in your code. Depending on the endpoint you want to reach, you might have to configure your headers though. UrlInterface is not a web framework which would automate these things for you.

        Here is some slightly obfuscated production code for posting towards an (https) endpoint:

        Bool DoRequestPost(
        	const maxon::String& endpoint, const maxon::CString& postData, Bool isFile = false, 
        	maxon::DataDictionary* responseAsDict = nullptr, 
        	maxon::BaseArray<maxon::DataDictionary>* responseAsArray = nullptr)
        {			
        	if (isFile)
        	{
        		additionalHeader.Set("Content-Type"_s, FormatString("multipart/form-data; boundary=@"_s, boundary)) iferr_cannot_fail("Cannot set content type"_s);
        		additionalHeader.Set("Some-Token"_s, "no-check"_s) iferr_cannot_fail("Cannot set Some-Token"_s);
        	}
        	else
        	{
        		additionalHeader.Set("Content-Type"_s, "application/json"_s) iferr_cannot_fail("Cannot set content-type"_s);
        		additionalHeader.Set("Accept"_s, "application/json"_s) iferr_cannot_fail("Cannot set accept datatype"_s);
        	}
        	url = maxon::Url();
        	url.Set(maxon::URLFLAGS::HTTP_ADDITIONAL_REQUEST_HEADER, additionalHeader) iferr_cannot_fail("Cannot set additional headers"_s);
        	url.Set(maxon::URLFLAGS::HTTP_POSTMETHOD, maxon::HTTPMETHOD::POST) iferr_cannot_fail("Cannot set httpmethod"_s);
        	url.Set(maxon::URLFLAGS::HTTP_POSTDATA, postData) iferr_cannot_fail("Cannot set post data"_s);
        	url.Set(maxon::URLFLAGS::HTTP_NO_PROXY_CACHING, true) iferr_cannot_fail("Cannot set NOPROXY");
        
        	return DoRequest(endpoint, responseAsDict, responseAsArray);
        }
        

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • R Offline
          Rox
          last edited by

          Thank you for the snippet Ferdinand.
          Timeout do still happen, but less frequently now.

          1 Reply Last reply Reply Quote 0
          • ferdinandF Offline
            ferdinand
            last edited by

            Timeouts should not happen unless the endpoint is indeed timing out. But as I said, I cannot help you unless you give me compilable code (i.e., a little self contained function) with which I can reproduce your claims. If possible, please also share your endpoint as it obviously plays a major role in this problem.

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • R Offline
              Rox
              last edited by

              For now I am good. If I need further help, I will send the endpoint and function by email.

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