IotHubBaseClient.SendTelemetryAsync Method

Definition

Sends a telemetry message to IoT hub.

public System.Threading.Tasks.Task SendTelemetryAsync (Microsoft.Azure.Devices.Client.TelemetryMessage message, System.Threading.CancellationToken cancellationToken = default);
member this.SendTelemetryAsync : Microsoft.Azure.Devices.Client.TelemetryMessage * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function SendTelemetryAsync (message As TelemetryMessage, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

message
TelemetryMessage

The message to send.

cancellationToken
CancellationToken

A cancellation token to cancel the operation.

Returns

Exceptions

Thrown when message is null.

Thrown when the operation has been canceled.

Thrown if the client instance is not opened already.

Thrown if a socket error occurs.

Thrown if an error occurs when performing an operation on a WebSocket connection.

Thrown if an I/O error occurs.

Thrown if an error occurs when communicating with IoT hub service.

Remarks

The client instance must be opened already.

In case of a transient issue, retrying the operation should work. In case of a non-transient issue, inspect the error details and take steps accordingly.

Applies to