Dhanyalakshmi K
Dhanyalakshmi K

Reputation: 11

Issue with ei_connect_xinit and Alternative Approaches for Establishing C-Node Connection

I’m facing an issue while connecting a C-node to an Erlang node using the ei library. The C-node is created successfully using the open_port/2 function, and I am able to spawn the C-node process. However, when trying to establish a connection between the Erlang node and the C-node using ei_connect_xinit, the function exits without returning anything, causing the program to terminate unexpectedly.

Setup:

C-Node Creation: I use the open_port/2 function with spawn to create the C-node process. The command executed is:

Port = open_port({spawn, Command}, [stream, nouse_stdio, exit_status])

This successfully returns the PID of the C-node process.

Connect to Erlang Node: I attempt to connect the C-node to the Erlang node using:

net_kernel:connect_node(c_node_name)

This enters the C-node’s C source file and executes ei_init successfully.

Failed Connection with ei_connect_xinit: The issue occurs when I call ei_connect_xinit with the following arguments:

node_name_without_ip = cnode_name
long_node_name_with_ip = [email protected]
ipv4_address_as_binary_data (binary structure with IP address)
cookie = "magic_cookie" (same for both Erlang and C-node)
creation = 0

Despite providing the correct arguments, ei_connect_xinit does not return anything and causes the program to exit unexpectedly.

Questions:

Why does ei_connect_xinit exit without returning anything?

Is there any known issue with this function that could cause it to exit unexpectedly (e.g., memory access issues, invalid arguments)? How can I debug and inspect the internal behavior of ei_connect_xinit to identify why it exits?

Are there alternative functions in the ei library for establishing a connection between a C-node and Erlang node?

How can I troubleshoot the connection issue?

Are there any logging mechanisms or environment variables I should enable to capture more detailed error messages or trace output?
What steps can I take to ensure that the arguments passed to ei_connect_xinit are valid and properly formatted?

Note:
The C-node and Erlang node are running on the same machine (localhost) with IP address 192.168.19.2. I’ve verified the magic cookie is the same for both the Erlang node and C-node.

I would greatly appreciate any help or suggestions on how to resolve this issue or debug the connection between the Erlang node and the C-node.

Upvotes: 1

Views: 20

Answers (0)

Related Questions