Jwt 运行coral.cloudiot.core apperas时出错

Jwt 运行coral.cloudiot.core apperas时出错,jwt,mqtt,gcloud,paho,google-coral,Jwt,Mqtt,Gcloud,Paho,Google Coral,我正在使用类()。这是的一个高级API 请在下面找到我的代码的简化版本: with CloudIot("./cloud_config.ini", config_section='DEFAULT') as cloud: while True: """if a defined if clause evalutes to True, the following method is executed.""" cloud.publish_mes

我正在使用类()。这是的一个高级API

请在下面找到我的代码的简化版本:

with CloudIot("./cloud_config.ini", config_section='DEFAULT') as cloud:
    while True:

        """if a defined if clause evalutes to True, 
        the following method is executed."""

        cloud.publish_message(message)
  • 端口443用于与gcloud iot集线器通信
  • 我尝试了qos=0和1
  • systemctl用于运行代码
  • 脚本每分钟最多发送48条消息
  • ntp端口被防火墙阻止(htpdate与crontab 5****一起使用)
一段时间后,将出现以下错误消息

Mar 08 03:17:33 mocha-orange systemd[1]: Started ANN Client Detection.
Mar 09 07:18:30 mocha-orange start_service_client[3957]: Exception in thread Thread-1:
Mar 09 07:18:30 mocha-orange start_service_client[3957]: Traceback (most recent call last):
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     self.run()
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3.7/threading.py", line 865, in run
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     self._target(*self._args, **self._kwargs)
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3/dist-packages/coral/cloudiot/core.py", line 196, in _token_update_loop
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     username='unused', password=self._create_jwt())
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3/dist-packages/coral/cloudiot/core.py", line 225, in _create_jwt
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     return self._jwt_inst.encode(token, self._private_key, algorithm=self._algorithm)
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3/dist-packages/jwt/api_jwt.py", line 65, in encode
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     json_payload, key, algorithm, headers, json_encoder
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3/dist-packages/jwt/api_jws.py", line 114, in encode
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     signature = alg_obj.sign(signing_input, key)
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3/dist-packages/coral/cloudiot/ecc608.py", line 132, in sign
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     return ecc608_hw_sign(msg)
Mar 09 07:18:30 mocha-orange start_service_client[3957]:   File "/usr/lib/python3/dist-packages/coral/cloudiot/ecc608.py", line 81, in ecc608_hw_sign
Mar 09 07:18:30 mocha-orange start_service_client[3957]:     assert status == 0
Mar 09 07:18:30 mocha-orange start_service_client[3957]: AssertionError

我不明白如何解决这个问题。我很感激任何提示。

我不熟悉珊瑚板,但熟悉云物联网。可能(!?)您没有正确配置设备以访问云物联网。当它尝试对要发送的消息进行签名时,断言出现在
ecc608
(它似乎实现了板上的加密芯片)。具体来说,您是否遵循以下步骤:?您是否将设备的ES256公钥添加到云物联网?您是否尝试了
enabled()
方法?这表明它检查了连接。该设备似乎配置正确,因为该服务在大部分时间内运行平稳,我确实遵循了中描述的步骤。在使用了几个小时后,上述错误就会累积。啊哈!在没有看到源代码的情况下,Coral库可能会发出一个短(几个小时)的JWT到期。JWT过期,因此您的代码失败。您可以通过将while循环从一小时缩短到一小时(或您确信的任何时间),然后使用CloudIoT重新启动
以强制重新创建JWT来测试这一点。另一种选择是,您超过了云IoT的配额。您可以使用云控制台对此进行检查:未超过配额。我觉得奇怪的是,coral.cloudiot.core每50分钟更新一次jwt令牌,jwt令牌在60分钟内有效。请参见第188行和第205行()。据《华尔街日报》报道,几小时后()。