# Cybus::Connection

The **Cybus::Connection** resource enables connectivity to external systems or devices using various protocols. The following describes its properties, supported protocols, and configuration examples.

## Connection Properties

| Property                    | Type     | Required |
| --------------------------- | -------- | -------- |
| [protocol](#protocol)       | `enum`   | Required |
| [targetState](#targetstate) | `enum`   | Optional |
| [agentName](#agentname)     | `string` | Optional |
| [connection](#connection)   | `object` | Required |

### protocol

Specifies the protocol to be used for establishing the connection.

* **Required**
* Type: `enum`

The value of this property **must** be one of the following:

* `Ads`
* `Bacnet`
* `EthernetIp`
* `Focas`
* `Hbmdaq`
* `Heidenhain`
* `Http`
* `Influxdb`
* `Kafka`
* `Modbus`
* `Mqtt`
* `Mssql`
* `Opcda`
* `Opcua`
* `S7`
* `Shdr`
* `Sinumerik`
* `Sopas`
* `Sql`
* `Systemstate`
* `Werma`

### targetState

Defines the desired state of the resource after startup.

* **Optional**
* Type: `enum`
* Allowed values:
  * `connected`
  * `disconnected`
* Default: `connected`

### agentName

Specifies the agent name if the protocol-mapper operates in distributed mode. For example, on a separate agent instance from Connectware. Use this property to identify the corresponding agent.

* **Optional**
* Type: `string`
* Default: `protocol-mapper`

### connection

Defines the connection details required for the specified protocol.

* **Required**
* Type: `object`

Each protocol has its own set of connection properties:

* `Ads` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/ads/adsconnection.md)
* `Bacnet` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/bacnet/bacnetconnection.md)
* `EthernetIp` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/ethernet-ip/ethernetipconnection.md)
* `Focas` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/focas/focasconnection.md)
* `Hbmdaq` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/hottinger-baldwin-messtechnik-hbm/hbmdaqconnection.md)
* `Heidenhain` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/heidenhain-dnc/heidenhainconnection.md)
* `Http` [Connection Properties](/2-1-2/connectors/enterprise-connectors/http-rest/httpconnection.md)
* `Influxdb` [Connection Properties](/2-1-2/connectors/enterprise-connectors/influxdb/influxdbconnection.md)
* `Kafka` [Connection Properties](/2-1-2/connectors/enterprise-connectors/kafka/kafkaconnection.md)
* `Modbus` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/modbus-tcp/modbusconnection.md)
* `Mqtt` [Connection Properties](/2-1-2/connectors/enterprise-connectors/mqtt/mqttconnection.md)
* `Mssql` [Connection Properties](/2-1-2/connectors/enterprise-connectors/mssql/mssqlconnection.md)
* `Opcda` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/opc-da/opcdaconnection.md)
* `Opcua` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/opc-ua/opc-ua-client/opcuaconnection.md)
* `S7` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/siemens-simatic-s7/s7connection.md)
* `Shdr` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/shdr/shdrconnection.md)
* `Sinumerik` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/sinumerik/sinumerikconnection.md)
* `Sopas` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/sopas/sopasconnection.md)
* `Sql` [Connection Properties](/2-1-2/connectors/enterprise-connectors/sql/sqlconnection.md)
* `Systemstate` [Connection Properties](https://github.com/cybusio/user-documentation/blob/release/2.1.2/documentation/generated/industry-protocol-details/SystemstateConnection.md)
* `Werma` [Connection Properties](/2-1-2/connectors/shop-floor-connectors/werma-win-ethernet/wermaconnection.md)

Most protocols include a `connectionStrategy` property to configure incremental delays between reconnection attempts. This typically includes:

* `initialDelay`: Time in milliseconds before the first reconnection attempt.
* `incrementFactor`: Multiplier applied to the delay after each attempt.
* `maxDelay`: Maximum delay in milliseconds for subsequent attempts.

Once the connection is re-established, the `initialDelay` resets to its original value. Note that MQTT, OPC UA, S7, and Sinumerik protocols use their own reconnection strategies, detailed in their respective documentation.

## Examples

### MQTT

{% code lineNumbers="true" %}

```yaml
mqttConnection:
  type: Cybus::Connection
  properties:
    protocol: Mqtt
    connection:
      host: broker
```

{% endcode %}

### OPC UA

{% code lineNumbers="true" %}

```yaml
opcuaConnection:
  type: Cybus::Connection
  properties:
    protocol: Opcua
    connection:
      host: 127.17.0.1
      port: 50000
      username: user
      password: user
```

{% endcode %}

### Modbus

{% code lineNumbers="true" %}

```yaml
modbusConnection:
  type: Cybus::Connection
  properties:
    agentName: edge-mapper # uses the protocol-mapper agent 'edge-mapper'
    protocol: Modbus
    connection:
      host: 172.17.0.1
      port: 10502
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cybus.io/2-1-2/documentation/services/service-commissioning-files/resources/cybus-connection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
