public ListenerLoop() { // Start re-populating signing keys. If the code-cached keys are out of date, it may take a few seconds to freshen. SigningKeys.UpdateKeyCache(); // Tracing setup var currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += BaseExceptionHandler; Trace.UseGlobalLock = false; Trace.AutoFlush = false; Trace.Listeners.Add(LocalTrace.Instance); Trace.TraceInformation("WrapperRoleListener coming up"); Trace.TraceInformation("Old connection limit was " + ServicePointManager.DefaultConnectionLimit); ServicePointManager.DefaultConnectionLimit = Parallelism; Trace.TraceInformation("New connection limit is " + ServicePointManager.DefaultConnectionLimit); ServicePointManager.ReusePort = true; ServicePointManager.EnableDnsRoundRobin = true; // can load balance with DNS ServicePointManager.SetTcpKeepAlive(false, 0, 0); _handler = new MainRequestHandler(new AadSecurityCheck()); }
/// <summary> /// Handle setup from the C++ side /// </summary> /// <param name="basePath">base path for the .Net binary</param> /// <param name="output">error message, if any</param> private static void WakeupCallback(string basePath, out string output) { BaseDirectory = Path.GetDirectoryName(basePath); output = null; // Do the wake up, similar to the ListenerLoop class try { // Start re-populating signing keys. If the code-cached keys are out of date, it may take a few seconds to freshen. SigningKeys.UpdateKeyCache(); // Set up the internal trace Trace.UseGlobalLock = false; Trace.AutoFlush = false; Trace.Listeners.Clear(); Trace.Listeners.Add(LocalTrace.Instance); ThreadPool.SetMaxThreads(ListenerLoop.Parallelism, ListenerLoop.Parallelism); ThreadPool.SetMinThreads(1, 1); // Load the config file var configurationMap = new ExeConfigurationFileMap { ExeConfigFilename = basePath + ".config" }; // this will load the app.config file. MainRequestHandler.ExplicitConfiguration = ConfigurationManager.OpenMappedExeConfiguration(configurationMap, ConfigurationUserLevel.None); // Check to see if HTTPS is bound in IIS if (GetBindings(BaseDirectory).Contains("https")) { MainRequestHandler.HttpsAvailable = true; } // Load the wrapper _core = new MainRequestHandler(new AadSecurityCheck()); } catch (Exception ex) { RecPrintException(ex); output = basePath + "\r\n" + ex; } }