From f361eaa5f1a2016ba3ec7ccc23f3db8d94e08d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 25 Jul 2023 15:52:24 +0200 Subject: [PATCH] Change attached runtime to establish a hidden connection (#2110) --- lib/livebook/runtime/attached.ex | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/livebook/runtime/attached.ex b/lib/livebook/runtime/attached.ex index eb29c6bf9..b5c9bb69e 100644 --- a/lib/livebook/runtime/attached.ex +++ b/lib/livebook/runtime/attached.ex @@ -39,7 +39,7 @@ defmodule Livebook.Runtime.Attached do # Set cookie for connecting to this specific node Node.set_cookie(node, cookie) - with :pong <- Node.ping(node), + with :ok <- connect_to_node(node), :ok <- check_attached_node_version(node) do server_pid = Livebook.Runtime.ErlDist.initialize(node, @@ -47,9 +47,15 @@ defmodule Livebook.Runtime.Attached do ) {:ok, %{runtime | node: node, server_pid: server_pid}} + end + end + + defp connect_to_node(node) do + with true <- :net_kernel.hidden_connect_node(node), + :pong <- Node.ping(node) do + :ok else - :pang -> {:error, "node #{inspect(node)} is unreachable"} - {:error, msg} -> {:error, msg} + _ -> {:error, "node #{inspect(node)} is unreachable"} end end