> For the complete documentation index, see [llms.txt](https://nso-docs.cisco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd_ha.md).

# econfd\_ha Module

An Erlang interface equivalent to the HA C-API (documented in confd\_lib\_ha(3)).

## Types

### ha\_node/0

```erlang
-type ha_node() :: #ha_node{}.
```

## Functions

### bemaster/2

```erlang
-spec bemaster(Socket, NodeId) -> Result
                  when
                      Socket :: econfd:socket(),
                      NodeId :: econfd:value(),
                      Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0), [econfd:value()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#value-0)

Instruct a HA node to be primary in the cluster.

### benone/1

```erlang
-spec benone(Socket) -> Result
                when
                    Socket :: econfd:socket(),
                    Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0)

Instruct a HA node to be nothing in the cluster.

### beprimary/2

```erlang
-spec beprimary(Socket, NodeId) -> Result
                   when
                       Socket :: econfd:socket(),
                       NodeId :: econfd:value(),
                       Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0), [econfd:value()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#value-0)

Instruct a HA node to be primary in the cluster.

### berelay/1

```erlang
-spec berelay(Socket) -> Result
                 when
                     Socket :: econfd:socket(),
                     Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0)

Instruct a HA secondary to be a relay for other secondaries.

### besecondary/4

```erlang
-spec besecondary(Socket, NodeId, PrimaryNodeId, WaitReplyBool) ->
                     Result
                     when
                         Socket :: econfd:socket(),
                         NodeId :: econfd:value(),
                         PrimaryNodeId :: ha_node(),
                         WaitReplyBool :: integer(),
                         Result :: ok | {error, econfd:error_reason()}.
```

Related types: [ha\_node()](#ha_node-0), [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0), [econfd:value()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#value-0)

Instruct a HA node to be secondary in the cluster where PrimaryNodeId is primary.

### beslave/4

```erlang
-spec beslave(Socket, NodeId, PrimaryNodeId, WaitReplyBool) -> Result
                 when
                     Socket :: econfd:socket(),
                     NodeId :: econfd:value(),
                     PrimaryNodeId :: ha_node(),
                     WaitReplyBool :: integer(),
                     Result :: ok | {error, econfd:error_reason()}.
```

Related types: [ha\_node()](#ha_node-0), [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0), [econfd:value()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#value-0)

Instruct a HA node to be secondary in the cluster where PrimaryNodeId is primary.

### close/1

```erlang
-spec close(Socket) -> Result
               when
                   Socket :: econfd:socket(),
                   Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0)

Close the HA connection.

### connect/2

```erlang
-spec connect(Path, Token) -> econfd:connect_result()
                 when Path :: string(), Token :: binary();
             (Address, Token) -> econfd:connect_result()
                 when Address :: econfd:ip(), Token :: binary().
```

Related types: [econfd:connect\_result()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#connect_result-0), [econfd:ip()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#ip-0)

### connect/3

```erlang
connect(Address, Port, Token)
```

### do\_connect/2

```erlang
-spec do_connect(Address, Token) -> econfd:connect_result()
                    when
                        Address ::
                            #econfd_conn_ip{} | #econfd_conn_local{},
                        Token :: binary().
```

Related types: [econfd:connect\_result()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#connect_result-0)

Connect to the HA subsystem.

If the port is changed it must also be changed in confd.conf To close a HA socket, use `close/1`.

### getstatus/1

```erlang
-spec getstatus(Socket) -> Result
                   when
                       Socket :: econfd:socket(),
                       Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0)

Request status from a HA node.

### secondary\_dead/2

```erlang
-spec secondary_dead(Socket, NodeId) -> Result
                        when
                            Socket :: econfd:socket(),
                            NodeId :: econfd:value(),
                            Result ::
                                ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0), [econfd:value()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#value-0)

Instruct ConfD that another node is dead.

### slave\_dead/2

```erlang
-spec slave_dead(Socket, NodeId) -> Result
                    when
                        Socket :: econfd:socket(),
                        NodeId :: econfd:value(),
                        Result :: ok | {error, econfd:error_reason()}.
```

Related types: [econfd:error\_reason()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#error_reason-0), [econfd:socket()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#socket-0), [econfd:value()](https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd.md#value-0)

Instruct ConfD that another node is dead.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://nso-docs.cisco.com/guides/nso-6.7/developer-reference/erlang/econfd_ha.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
