Hello SDK Team,
I"m trying to connect to the MQTT messages using AWSIoTPythonSDK, with python version 3.7. Also I have applied the workaround patch in python3.7/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py as mentioned.
But still I'm facing with Bad file descriptor issue with below error message. Could you please help me to resolve this.
ERROR:
OSError Traceback (most recent call last)
in
27 myMQTTClient.on_connect = connect
28 myMQTTClient.on_message = message
---> 29 myMQTTClient.connect()
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/MQTTLib.py in connect(self, keepAliveIntervalSecond)
511 """
512 self._load_callbacks()
--> 513 return self._mqtt_core.connect(keepAliveIntervalSecond)
514
515 def connectAsync(self, keepAliveIntervalSecond=600, ackCallback=None):
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py in connect(self, keep_alive_sec)
194 self._logger.info("Performing sync connect...")
195 event = Event()
--> 196 self.connect_async(keep_alive_sec, self._create_blocking_ack_callback(event))
197 if not event.wait(self._connect_disconnect_timeout_sec):
198 self._logger.error("Connect timed out")
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py in connect_async(self, keep_alive_sec, ack_callback)
221 self._logger.debug("Event consumer stopped")
222 self._client_status.set_status(ClientStatus.IDLE)
--> 223 raise e
224
225 return FixedEventMids.CONNACK_MID
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py in connect_async(self, keep_alive_sec, ack_callback)
209 try:
210 self._client_status.set_status(ClientStatus.CONNECT)
--> 211 rc = self._internal_async_client.connect(keep_alive_sec, ack_callback)
212 if MQTT_ERR_SUCCESS != rc:
213 self._logger.error("Connect error: %d", rc)
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/internal/clients.py in connect(self, keep_alive_sec, ack_callback)
120 self._event_callback_map[FixedEventMids.MESSAGE_MID] = self._create_converted_on_message_callback()
121
--> 122 rc = self._paho_client.connect(host, port, keep_alive_sec)
123 if MQTT_ERR_SUCCESS == rc:
124 self.start_background_network_io()
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py in connect(self, host, port, keepalive, bind_address)
663 """
664 self.connect_async(host, port, keepalive, bind_address)
--> 665 return self.reconnect()
666
667 def connect_srv(self, domain=None, keepalive=60, bind_address=""):
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py in reconnect(self)
833 cert_reqs=self._tls_cert_reqs,
834 ssl_version=self._tls_version,
--> 835 ciphers=self._tls_ciphers)
836 else:
837 print("Port number -->", self._port)
/opt/anaconda3/lib/python3.7/ssl.py in wrap_socket(sock, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect, suppress_ragged_eofs, ciphers)
1236 sock=sock, server_side=server_side,
1237 do_handshake_on_connect=do_handshake_on_connect,
-> 1238 suppress_ragged_eofs=suppress_ragged_eofs
1239 )
1240
/opt/anaconda3/lib/python3.7/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
421 server_hostname=server_hostname,
422 context=self,
--> 423 session=session
424 )
425
/opt/anaconda3/lib/python3.7/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
815 suppress_ragged_eofs=True, server_hostname=None,
816 context=None, session=None):
--> 817 if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
818 raise NotImplementedError("only stream sockets are supported")
819 if server_side:
OSError: [Errno 9] Bad file descriptor
Hello SDK Team,
I"m trying to connect to the MQTT messages using AWSIoTPythonSDK, with python version 3.7. Also I have applied the workaround patch in python3.7/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py as mentioned.
But still I'm facing with Bad file descriptor issue with below error message. Could you please help me to resolve this.
ERROR:
OSError Traceback (most recent call last)
in
27 myMQTTClient.on_connect = connect
28 myMQTTClient.on_message = message
---> 29 myMQTTClient.connect()
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/MQTTLib.py in connect(self, keepAliveIntervalSecond)
511 """
512 self._load_callbacks()
--> 513 return self._mqtt_core.connect(keepAliveIntervalSecond)
514
515 def connectAsync(self, keepAliveIntervalSecond=600, ackCallback=None):
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py in connect(self, keep_alive_sec)
194 self._logger.info("Performing sync connect...")
195 event = Event()
--> 196 self.connect_async(keep_alive_sec, self._create_blocking_ack_callback(event))
197 if not event.wait(self._connect_disconnect_timeout_sec):
198 self._logger.error("Connect timed out")
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py in connect_async(self, keep_alive_sec, ack_callback)
221 self._logger.debug("Event consumer stopped")
222 self._client_status.set_status(ClientStatus.IDLE)
--> 223 raise e
224
225 return FixedEventMids.CONNACK_MID
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py in connect_async(self, keep_alive_sec, ack_callback)
209 try:
210 self._client_status.set_status(ClientStatus.CONNECT)
--> 211 rc = self._internal_async_client.connect(keep_alive_sec, ack_callback)
212 if MQTT_ERR_SUCCESS != rc:
213 self._logger.error("Connect error: %d", rc)
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/internal/clients.py in connect(self, keep_alive_sec, ack_callback)
120 self._event_callback_map[FixedEventMids.MESSAGE_MID] = self._create_converted_on_message_callback()
121
--> 122 rc = self._paho_client.connect(host, port, keep_alive_sec)
123 if MQTT_ERR_SUCCESS == rc:
124 self.start_background_network_io()
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py in connect(self, host, port, keepalive, bind_address)
663 """
664 self.connect_async(host, port, keepalive, bind_address)
--> 665 return self.reconnect()
666
667 def connect_srv(self, domain=None, keepalive=60, bind_address=""):
/opt/anaconda3/lib/python3.7/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py in reconnect(self)
833 cert_reqs=self._tls_cert_reqs,
834 ssl_version=self._tls_version,
--> 835 ciphers=self._tls_ciphers)
836 else:
837 print("Port number -->", self._port)
/opt/anaconda3/lib/python3.7/ssl.py in wrap_socket(sock, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect, suppress_ragged_eofs, ciphers)
1236 sock=sock, server_side=server_side,
1237 do_handshake_on_connect=do_handshake_on_connect,
-> 1238 suppress_ragged_eofs=suppress_ragged_eofs
1239 )
1240
/opt/anaconda3/lib/python3.7/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
421 server_hostname=server_hostname,
422 context=self,
--> 423 session=session
424 )
425
/opt/anaconda3/lib/python3.7/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
815 suppress_ragged_eofs=True, server_hostname=None,
816 context=None, session=None):
--> 817 if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
818 raise NotImplementedError("only stream sockets are supported")
819 if server_side:
OSError: [Errno 9] Bad file descriptor