Help Center/ IoT Device Access/ API Reference/ Security Tunnel WebSocket API Reference/ Exchanging Messages Through Secure Tunnel Protocols
Updated on 2024-12-31 GMT+08:00

Exchanging Messages Through Secure Tunnel Protocols

Once a WebSocket connection is established between the application and device, they communicate using a secure tunnel protocol. The following table lists the data format.

Parameter

Type

Description

operation_type

String

Explanation: Data type.

Value range:

  • connect_tunnel: The platform notifies the application that the device is connected to the WebSocket.
  • connect: The application delivers the SSH channel connection parameters to the device.
  • connect_response: The device reports a connection response to the application.
  • command: The application delivers the SSH command to the device.
  • command_response: The device reports the SSH command execution response to the application.
  • disconnect: When the platform disconnects the WebSocket connection, the platform sends data to the application.
  • ping: upstream heartbeat message.
  • pong: The platform sends a heartbeat response.

tunnel_service_type

String

Explanation: Service type corresponding to tunnel communication.

Value range: ssh.

request_id

String

Explanation: Session IDs of different data types.

Constraint: The value must be unique in the current secure tunnel.

data

Object

Explanation: Data to be transmitted.

Example

  • The platform notifies the application that the device is connected to the WebSocket.
{
    "operation_type":"connect_tunnel"
    "tunnel_service_type": "ssh",
    "request_id":"xxx",
    "data": null
}
  • The application delivers the SSH channel connection parameters to the device.
{
    "operation_type": "connect",
    "tunnel_service_type": "ssh",
    "request_id":"xxx",
    "data": {
        "username":"xxx",
        "password": ""
    }
}
  • The device reports a connection response to the application.
{
    "operation_type":"connect_response"
    "tunnel_service_type": "ssh",
    "request_id":"xxx",
    "data": "xx"
}
  • The application delivers the SSH command to the device.
{
    "operation_type":"command",
    "tunnel_service_type": "ssh",
    "request_id":"xxx",
    "data": "xxx"
}
  • The device reports the SSH command execution response to the application.
{
    "operation_type":"command_response"
    "tunnel_service_type": "ssh",
    "request_id":"xxx",
    "data": null
}
  • When the platform disconnects the WebSocket connection, the platform sends data to the application.
{
    "operation_type":"disconnect",
    "tunnel_service_type": "ssh",
    "request_id":"xxx",
    "data": {
        "status_code":"xxx",
        "status_msg":"xxx"
    }
}