Trickle error :- failed:connection refused

Trickle error :- failed:connection refused

我有一个 Azure Iot Hub 端点,我必须在其中发送一些数据(考虑小字符串)。我想设置向 url 发送数据的速度,我正在使用 Trickle 来实现。

我以为

trickle -d 30 -u 30 wget http://armtest1.azure-devices.net 

会完成这项工作,但它正在显示

failed: Connection refused

也试过这样:

trickle -d 30 -u 30 wget --user=[myusername] --password=[mypassword] --auth-no-challenge http://armtest1.azure-devices.net

但仍然出现同样的错误。

如果你们能指出我的错误并给我一个使用 trickle 实现这个的方法,那将非常有帮助。

Azure IoT 中心通过根据共享访问策略和身份注册表安全凭证验证令牌来授予对端点的访问权限。 Azure IoT Hub 支持 MQTT、AMQP 和 HTTPS,这些支持的协议以不同的方式传输令牌 ways.HTTPS 通过在授权请求 header 中包含有效令牌来实现身份验证。 如果您想使用 REST API 访问(发送数据)到 Azure IoT Hub,现有设备需要 specified.Please 尝试执行以下命令:

trickle -s -d 30 -u 30 \
wget --header="Authorization:<generated SAS token for device>" \
     --header="Content-Type:application/json" \
     --post-data '<your data in json style>' \
     "https://<your-iothub-host>.azure-devices.net/devices/<device id>/messages/events?api-version=2016-02-03"

在命令中,有一点需要说明。

  • 为设备生成 SAS 令牌:您可以使用 Device Explorer to generate the token.Please refer to the step 2 in this article(Sending events to IOT Hub over HTTP via REST)。
  • your data in json style:要发送到 IoT 中心的数据。它采用 JSON 格式。
  • your-iothub-host:您可以在Azure中获取IoT Hub的主机名Portal.This是您创建IoT Hub时的名称。

当您成功执行命令后,会有如下响应:

Connecting to <your-iothub-host>.azure-devices.net (<your-iothub-host>.azure-devices.net)|<ipaddress>|:443... connected.
HTTP request sent, awaiting response... 204 No Content
2018-01-03 22:33:53 (0.00 B/s) - ‘events?api-version=2016-02-03’ saved [0]

并且,IoT 中心将收到消息,您可以通过设备资源管理器monitor the events