订阅主题QoS.EXACTLY_ONCE时使用awsiotsdk,遇到AWS_ERROR_MQTT_UNEXPECTED_HANGUP

Using awsiotsdk when subscribing to a topic with QoS.EXACTLY_ONCE, encountering AWS_ERROR_MQTT_UNEXPECTED_HANGUP

我在 awsiotsdk 中关注 the example pub/sub

# boilerplate setup code omitted
self.mqtt_connection = awsiot.mqtt_connection_builder.websockets_with_default_aws_signing(...)
connect_future = self.mqtt_connection.connect()
print('Connected: ', connect_future.result())
[OUTPUT] Connected:  {'session_present': True}

连接过程中的一切看起来都很好。接下来我订阅一个话题:

def mycallback(*args, **kwargs):
  print("mycallback: ", args, kwargs)

subscribe_future, packet_id = self.mqtt_connection.subscribe(
  topic='test/topic',
  callback=mycallback,
  qos=awscrt.mqtt.QoS.AT_LEAST_ONCE
)
subscribe_future.result()

以上代码有效,我稍后可以成功发布和接收消息。

但是,如果我将 QoS 更改为 EXACTLY_ONCE,我会收到以下错误:

In _on_connection_interrupted: (), {'connection': <awscrt.mqtt.Connection object at 0x7f804acfea40>, 'error': AwsCrtError(name='AWS_ERROR_MQTT_UNEXPECTED_HANGUP', message='The connection was closed unexpectedly.', code=5134)}
In _on_connection_resumed: (), {'connection': <awscrt.mqtt.Connection object at 0x7f804acfea40>, 'return_code': <ConnectReturnCode.ACCEPTED: 0>, 'session_present': True}
In _on_connection_interrupted: (), {'connection': <awscrt.mqtt.Connection object at 0x7f804acfea40>, 'error': AwsCrtError(name='AWS_ERROR_MQTT_UNEXPECTED_HANGUP', message='The connection was closed unexpectedly.', code=5134)}
In _on_connection_resumed: (), {'connection': <awscrt.mqtt.Connection object at 0x7f804acfea40>, 'return_code': <ConnectReturnCode.ACCEPTED: 0>, 'session_present': True}
<repeats a few more lines>

EXACTLY_ONCE 有什么问题?好像是我想要的QoS。

EXACTLY_ONCE (MQTT QOS level 2) is not currently supported by the AWS IoT Core server. This is mentioned in the source:

QoS 2 - Exactly once delivery
This is the highest quality of service, for use when neither loss nor
duplication of messages are acceptable. There is an increased overhead
associated with this quality of service.

Note that, while this client supports QoS 2, the AWS IoT Core server
does not support QoS 2 at time of writing (May 2020).

并在 developer guide 中:

The MQTT protocol defines a third level of QoS, level 2, but AWS IoT does not support it.