question about greengrass discovery (basic_discovery.py, time out on another device)

0

Hi, I'm following the tutorial (https://docs.aws.amazon.com/greengrass/v2/developerguide/client-devices-tutorial.html) with my PC for a test. and I'm at running the basic_discovery.py stage.

I created a ClientDeivce1 and got certificate and keys, added it as a client Device in associated client devices list in the core device and MQTT broker has endpoint ip. Then I ran the basic_discovery.py in the same PC. And it worked. It sent out messages and I can see the message in MQTT test client, Good! So at the moment, my PC acted as both Core Device and ClientDevice1

However, I want to run basic_discovery.py in another machine, e.g) my laptop (eventually raspberry pi which is being delivered to me soon) So for another test, I ran basic_discovery.py on my laptop with the certificate and the keys (since running basic_discovery.py on my PC was just a test) So basically I want my laptop to be ClientDevice1

And I'm getting error: Trying core arn:aws:iot:ap-southeast-2:xxxxxxxxxxxx:thing/GreengrassQuickStartCore-18bacbd1cda at host <endpoint ip> port 8883 [ERROR] [2023-11-15T04:06:12Z] [00007fdd6d760700] [socket] - id=0x7fdd60000ca0 fd=9: timed out, shutting down. Connection failed with exception AWS_IO_SOCKET_TIMEOUT: socket operation timed out. [ERROR] [2023-11-15T04:06:12Z] [00007fdd6d760700] [socket] - id=0x7fdd60000ca0 fd=-1: connection failure All connection attempts failed [ERROR] [2023-11-15T04:06:12Z] [00007fdd6d760700] [channel-bootstrap] - id=0xe138e0: Connection failed with error_code 1048. [ERROR] [2023-11-15T04:06:12Z] [00007fdd6ed80740] [mqtt-client] - id=0xfdda40: Connection is not open, and may not be closed

I thought this would work but didn't. What do I need to do to make the 2nd scenario working? Both of my pc and laptop are connected to the same wifi. Do I need to do something special?

Thank you!

  • Most likely this indicates that a firewall is blocking the connection. What happens if you do not use discovery? Just manually use any MQTT client and try to connect to your Greengrass core device's IP address on port 8883.

  • Thank you for the feedback, Michael. I checked https://aws.amazon.com/about-aws/whats-new/2018/02/aws-iot-core-now-supports-mqtt-connections-with-certificate-based-client-authentication-on-port-443/ and it seems like related ports are 443, 8443, 8883. So I went to windows firewall> Inbound Rules > and created a rule with TCP and port with 443, 8443, 8883 for local/remote port. but didnt work

    I also tried to use any MQTT client as suggested but I'm very new to IoT and never used other MQTT at all. So I just googled and tried this:

    import time from paho.mqtt import client as mqtt_client from pathlib import Path broker = 'IP of core dev' port = 8883 topic = "clients/MyClientDevice1/temp"

    client_id = f'publish-{random.randint(0, 1000)}' def connect_mqtt(): def on_connect(client, userdata, flags, rc): if rc == 0: print("Connected to MQTT Broker!") else: print("Failed to connect, return code %d\n", rc) client = mqtt_client.Client(client_id) thing_name = 'GreengrassClientDevice1' ca_path = str(Path(f'/certs/{thing_name}/AmazonRootCA1.pem').expanduser()) cert_path = str(Path(f'/certs/{thing_name}/certificate.pem.crt').expanduser()) private_key_path = str(Path(f'~/certs/{thing_name}/private.pem.key').expanduser()) client.tls_set( ca_certs=ca_path, certfile=cert_path, keyfile=private_key_path ) And. the error was similar: timed out

  • sorry.. seems like this text box has pretty tight limit. (I couldnt fit text into comments) anyway, I'm still having trouble. is there anything else I can try? Thank you in advance!

  • Do you see any log entries in greengrass.log file on the Greengrass Core Device during the same time that you attempt to connect?

    You can use any MQTT client, there are many GUI clients such as MQTT X available.

    Try following: https://www.youtube.com/watch?v=tN0DQlQy2kM

  • Hi, Michael. The youtube video is the one I was following before to get to this stage, thanks for the suggestion thou.

    I also tried MQTTX client. Probably I don't know how to use it but here are my findings.

    If I use MQTTX client on the same device where the core device is setup, I see the greengrass logging messages like following:

    2023-11-16T20:06:14.832Z [INFO] (nioEventLoopGroup-7-19) io.moquette.broker.metrics.MQTTMessageLogger: Channel Inactive. {} 2023-11-16T20:06:19.233Z [INFO] (nioEventLoopGroup-7-20) io.moquette.broker.metrics.MQTTMessageLogger: Channel Inactive. {} 2023-11-16T20:06:23.633Z [INFO] (nioEventLoopGroup-7-21) io.moquette.broker.metrics.MQTTMessageLogger: Channel Inactive. {}

    I didn't get MQTTX client to connect but at least some activity is happening on the core device (greengrass.log)

    If I use MQTTX client on the different device (my laptop), I don't see anything showing up in the greengrass log. And it is the same for basic_discovery.py, no logging on the greengrass.log

J
질문됨 6달 전274회 조회
1개 답변
0
수락된 답변

It was due to how network is configured. It was due to me running core device in wsl 2 which configures ip differently. I just ran a core device in windows directly since this was just an experiment. and it worked. Thank you Michael for all the feedback!

J
답변함 6달 전

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

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

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