Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'MsgHandler' object has no attribute 'connect' #2

Open
scottbasgaard opened this issue Nov 9, 2020 · 10 comments
Open

Comments

@scottbasgaard
Copy link

Looking at AWSIoTPythonSDK/MQTTMsgHandler.py there is no connect method it seems. Known issue?

>>> Packet sent. (Length: 2)
Packet sent. (Length: 2)
Packet sent. (Length: 2)
Packet sent. (Length: 2)
Packet sent. (Length: 2)
Unhandled exception in thread started by <bound_method>
Traceback (most recent call last):
  File "AWSIoTPythonSDK/MQTTMsgHandler.py", line 258, in _io_thread_func
  File "AWSIoTPythonSDK/MQTTMsgHandler.py", line 244, in _verify_connection_state
AttributeError: 'MsgHandler' object has no attribute 'connect'
@ysefwakil
Copy link

Same issue here

@ysefwakil
Copy link

I used my phones hotspot and it worked so it might be a security issue within your network, try using a hotspot

@grahamPatico
Copy link

Same issue.

@stevieraysean
Copy link

In MQTTMsgHandler.py I replaced the calls to self.connect() with self.createSocketConnection() and I'm able to connect and publish to AWSIoT now.

@grahamPatico
Copy link

Thanks @stevieraysean. "Replaced the calls to self.connect() with self.createSocketConnection()" seems to be what the developers intended.

I am still having an issue with connecting back to the network after a disconnect event with error 'Socket create error: [Errno 202] EAI_FAIL' occuring after a couple hours of successful packet sents. This error keeps printing. The program works perfectly after resetting. Any ideas?

@stevieraysean
Copy link

That’s weird. What method are you connecting with? Wifi? LTE?

I’ve got a G01 on wifi that’s been sending a message every 5 seconds for the last 5.5 hours. 4000+ messages. Will see how it goes over the next few days..

@grahamPatico
Copy link

grahamPatico commented Apr 1, 2021

I am using a GPy over LTE using Pybytes configuration. The issue may not be a socket problem as much as it is the LTE isn't reconnecting after a disconnect event. I will try add some lte disconnect/reconnect. Maybe that will help.

@stevieraysean
Copy link

stevieraysean commented May 7, 2021

@grahamPatico i've encountered this issue also.
only way i could find to fix it without restarting was to kill the msghandler thread are reinitialize the whole thing. it's like the socket gets corrupted or something... basically if you don't have a network connection you don't want this aws thread running..

anyway, ended up fixing by adding if any exception happened in _send_packet(self, packet):
self._poll.unregister(self._sock)
self._sock.close()
self._sock = None
self._shutdown = True

then in _io_thread_func(self):
if self._shutdown == True:
_thread.exit()

then back in main or wherever when you detect network re-connection initialize the whole aws object and init again:
aws = aws_connection()
aws.init()

I've had issues with _thread.exit() in other parts of my code, but it seems ok here.

hope that helps....

Edit: My connection is over wifi, so usually good. but in the case the wifi router reset or something i needed to be able to shut this down and bring it back up again..

@grahamPatico
Copy link

@stevieraysean
Have you seen this other aws mqtt library?
https://github.com/pycom/pycom-libraries/tree/master/lib/mqtt_aws

@grahamPatico
Copy link

This library is more complete. https://github.com/pycom/pycom-libraries/tree/master/lib/mqtt_aws

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants