public async Task <bool> SendShuttingDownMessage() { try { AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); // string localIP = $"{LocalIPAddress()}"; string localIP = "localhost"; // TODO: bootNode may not be on the same host, and may be using https string bootNodeIP = $"http://localhost:{_options.ServerRPCPort}"; _logger.LogInformation($"Attempting connect to channel is: {bootNodeIP} and my ip is {localIP}"); var channel = GrpcChannel.ForAddress(bootNodeIP); var client = new BootNode.BootNodeClient(channel); var reply = client.SendSimpleMessage(new SimpleMessage { ClientAddr = $"http://{localIP}:{_options.RPCPort}" }); _logger.LogInformation("BootNode says: " + reply.Message); return(true); } catch (Exception ex) { _logger.LogInformation($"ERROR: {ex.Message}"); if (ex.InnerException != null) { _logger.LogInformation($"INNER EXCEPTION: {ex.InnerException}"); } else { _logger.LogInformation("no more details"); } return(false); } }
public async Task <bool> SendShuttingDownMessage(string clientNodeAddress) { try { AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); string localIP = $"{LocalIPAddress()}"; _logger.LogInformation($"Attempting connect to channel is: {clientNodeAddress} and my ip is {localIP}"); var channel = GrpcChannel.ForAddress(clientNodeAddress); var client = new BootNode.BootNodeClient(channel); var reply = client.SendSimpleMessage(new SimpleMessage { ClientAddr = $"http://{localIP}:{_options.RPCPort}" }); _logger.LogInformation("ChildNode reply: " + reply.Message); return(true); } catch (Exception ex) { _logger.LogInformation($"ERROR: {ex.Message}"); if (ex.InnerException != null) { _logger.LogInformation($"INNER EXCEPTION: {ex.InnerException}"); } else { _logger.LogInformation("no more details"); } return(false); } }
public async Task <bool> ConnectToBootNode() { { try { Task.Delay(2000).Wait(); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); Console.WriteLine($"Attempting connect to channel is: http://localhost:{_options.ServerRPCPort}"); var channel = GrpcChannel.ForAddress($"http://localhost:{_options.ServerRPCPort}"); var client = new BootNode.BootNodeClient(channel); var reply = client.AddLink(new LinkRequest { ClientAddr = $"http://localhost:{_options.RPCPort}" }); Console.WriteLine("BootNode says: " + reply.Message); return(true); } catch (Exception ex) { Console.WriteLine($"ERROR: {ex.Message}"); if (ex.InnerException != null) { Console.WriteLine($"INNER EXCEPTION: {ex.InnerException}"); } else { Console.WriteLine("no more details"); } return(false); } } }