recv_name_old function_clause

Hello, I’m a beginner. Recently my server always returns an error message:

Error in process <0.29709.65> on node 'X@Y' with exit value:
{function_clause,[{dist_util,recv_name_old,[{hs_data,<0.62.0>,undefined,'X@Y',#Port<0.13427>,<0.29707.65>,0,[],undefined,undefined,undefined,fun inet_tcp:send/2,fun inet_tcp:recv/3,#Fun<inet_tcp_dist.0.90093225>,#Fun<inet_tcp_dist.1.90093225>,#Fun<inet_tcp_dist.2.90093225>,#Fun<inet_tcp_dist.3.90093225>,#Fun<inet_tcp_dist.4.90093225>,fun inet_tcp_dist:getstat/1,normal,fun inet_tcp_dist:setopts/2,fun inet_tcp_dist:getopts/2,undefined,undefined,undefined,undefined,undefined,undefined},"n"],[{file,"dist_util.erl"},{line,767}]},{dist_util,handshake_other_started,1,[{file,"dist_util.erl"},{line,199}]}]}

I changed my node name to X@Y
I checked the error location and received an “n” when I received the first handshake message from the connector.

recv_name(#hs_data{socket = Socket, f_recv = Recv} = HSData) ->
   case Recv(Socket, 0, infinity) of
       {ok, [$n | _] = Data} ->
           recv_name_old(HSData, Data);
       {ok, [$N | _] = Data} ->
           recv_name_new(HSData, Data);
   _ ->
       ?shutdown(no_node)
   end.

Here the match is successful, but the corresponding argument cannot be matched after entering the method “recv_name_old”, resulting in an error

recv_name_old(HSData,
             [$n, V1, V0, F3, F2, F1, F0 | Node] = Data) ->
    <<_Version:16>> = <<V1,V0>>,
    <<Flags:32>> = <<F3,F2,F1,F0>>,
    ?trace("recv_name: 'n' node=~p version=~w\n", [Node, _Version]),
    case is_node_name(Node) of
        true ->
            check_allowed(HSData, Node),
            {Flags, list_to_atom(Node), ?CREATION_UNKNOWN, ?ERL_DIST_VER_5};
        false ->
            ?shutdown(Data)
    end.

So where did the unexpected handshake message “n” come from? How can you find the source or avoid it?

2 Likes
{function_clause,[{dist_util,recv_name_old,[{hs_data,...},"n"]...

"n" not match [$n, V1, V0, F3, F2, F1, F0 | Node]

3 Likes

Thank you very much for your answer, maybe there is something wrong with my description. I understand error because the parameters of the “n” does not match [$n, V1, where V0, F3, F2, F1 and F0 | Node]. But this part of the code seems to be setting up a network connection, and WHAT I’m not quite sure about is why I get the weird “N” parameter on the first handshake.

case Recv(Socket, 0, infinity) of
       {ok,} ->
           recv_name_old(HSData, Data);
       {ok, [$N | _] = Data} ->
           recv_name_new(HSData, Data);

It even in the message is received first match “[$n | _] = Data” when the match is successful But in “recv_name_old (HSData, Data)” method after quote us “not match” error

Error in process <0.29709.65> on node 'X@Y' with exit value:
{function_clause,[{dist_util,recv_name_old,[{hs_data,<0.62.0>,undefined,'X@Y',#Port<0.13427>,<0.29707.65>,0,[],undefined,undefined,undefined,fun inet_tcp:send/2,fun inet_tcp:recv/3,#Fun<inet_tcp_dist.0.90093225>,#Fun<inet_tcp_dist.1.90093225>,#Fun<inet_tcp_dist.2.90093225>,#Fun<inet_tcp_dist.3.90093225>,#Fun<inet_tcp_dist.4.90093225>,fun inet_tcp_dist:getstat/1,normal,fun inet_tcp_dist:setopts/2,fun inet_tcp_dist:getopts/2,undefined,undefined,undefined,undefined,undefined,undefined},"n"],[{file,"dist_util.erl"},{line,767}]},{dist_util,handshake_other_started,1,[{file,"dist_util.erl"},{line,199}]}]}

This error would be thrown at my server at irregular times every day. I tried to find the problem, but could not solve it. It bothered me so much that I wanted to post and ask everyone

2 Likes

Also, the version of Erlang I currently use is erl-23.3.4.10

1 Like

oh, sorry, it’s a bulid in module :sweat_smile:
I’m not an expert in erlang.
but I find some code in erl_epmd:

-define(EPMD_NAMES, $n).
do_get_names(Socket) ->
    case gen_tcp:send(Socket, [?int16(1),?EPMD_NAMES]) of

maybe you can try erl_epmd:names/0
hope it can help you :grinning:

3 Likes

OK, thank you very much for your answer. I’ll try to look at this part of the code according to the module you provided.

2 Likes