AWSIoTPythonSDK - OSError: [WinError 10038] An operation was attempted on something that is not a socket

0

Trying to connect to a IoT thing via code to simulate a device with Python. This code was working before and now I'm getting this error.

The code is straight forward.

import time as t
from datetime import datetime
import AWSIoTPythonSDK.MQTTLib as AWSIoTPyMQTT

def helloworld(self, params, packet):
    print(packet.payload)


myCLIENT = AWSIoTPyMQTT.AWSIoTMQTTClient('test_thing')
myCLIENT.configureEndpoint('myEndPoint', 8883)
myCLIENT.configureCredentials("Path to AmazonRootCA1.pem", "Path to private.pem.key", "Path to certificate.pem.crt")

myCLIENT.configureOfflinePublishQueueing(-1)  # Infinite offline Publish queueing
myCLIENT.configureDrainingFrequency(2)  # Draining: 2 Hz
myCLIENT.configureConnectDisconnectTimeout(10)  # 10 sec
myCLIENT.configureMQTTOperationTimeout(5)  # 5 sec

print('Connecting...')
myCLIENT.connect()
print('Connected')


def loop():
    temperature = 20
    humidity = 67

    while True:
        curr_dt = datetime.now()
        myCLIENT.publish(
            topic='test_thing/test',
            payload='{"timestamp": ' + str(int(round(curr_dt.timestamp()))) + ', "temperature": ' + str(temperature) + ', "humidity":' + str(humidity)+', "project_id": 1}',
            QoS=1)
        if temperature < 25:
            temperature += 0.01
            humidity += 0.005
        else:
            temperature -= 0.01
            humidity -= 0.005
        t.sleep(1)


if __name__ == '__main__':
    try:
        loop()
    except KeyboardInterrupt:
        myCLIENT.disconnect()

And I'm getting this error when trying to connect

test_thing.py:24: in <module>
    myCLIENT.connect()
..\..\Anaconda3\lib\site-packages\AWSIoTPythonSDK\MQTTLib.py:355: in connect
    return self._mqttCore.connect(keepAliveIntervalSecond)
..\..\Anaconda3\lib\site-packages\AWSIoTPythonSDK\core\protocol\mqttCore.py:282: in connect
    self._pahoClient.connect(self._host, self._port, keepAliveInterval)  # Throw exception...
..\..\Anaconda3\lib\site-packages\AWSIoTPythonSDK\core\protocol\paho\client.py:655: in connect
    return self.reconnect()
..\..\Anaconda3\lib\site-packages\AWSIoTPythonSDK\core\protocol\paho\client.py:807: in reconnect
    self._sock.setblocking(0)
E   OSError: [WinError 10038] An operation was attempted on something that is not a socket

Any ideas where the problem might be?

질문됨 일 년 전61회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠