Exchange Server
Microsoft 클라이언트/서버 메시징 및 공동 작업 소프트웨어 제품군.
질문 11개
이 브라우저는 더 이상 지원되지 않습니다.
최신 기능, 보안 업데이트, 기술 지원을 이용하려면 Microsoft Edge로 업그레이드하세요.
from azure.iot.device import IoTHubDeviceClient, Message
import threading
import time
CONNECTION_STRING = "HostName=ID.azure-devices.net;DeviceId=sample;SharedAccessKey=???"
def message_handler(message):
print("Received message from Azure IoT Hub:")
print(message.data.decode("utf-8"))
print("")
def main():
client = IoTHubDeviceClient.create_from_connection_string(CONNECTION_STRING)
client.connect()
# 메시지 핸들러 설정
client.on_message_received = message_handler
try:
# 메인 스레드가 종료되지 않도록 유지
while True:
time.sleep(1)
except KeyboardInterrupt:
print("IoTHubDeviceClient sample stopped")
if __name__ == "__main__":
main()
오류 메시지는 다음과 같습니다 .
Exception caught in background thread. Unable to handle.
['azure.iot.device.common.transport_exceptions.ConnectionDroppedError: Unexpected disconnection\n']
코드가 잘못되었거나, 추가적인 방법이 있나요?