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

AWS IoT and publish freeze on Nerves #127

Open
MAkcanca opened this issue Nov 29, 2020 · 3 comments
Open

AWS IoT and publish freeze on Nerves #127

MAkcanca opened this issue Nov 29, 2020 · 3 comments

Comments

@MAkcanca
Copy link

MAkcanca commented Nov 29, 2020

I'm trying to write an example project for Aws IoT core MQTT connection with Tortoise, but whenever I try to publish a message, application hangs. It's running on Rpi0
I'm fairly new to Elixir and can't say that this is the right approach, but the lack of example projects does not make things easier to learn either.
Here is what I do to send a message

        client_opts = [ 
            client_id: "testdev01",
            handler: {Tortoise.Handler.Logger, []},
            server: {Tortoise.Transport.SSL,
            cacerts: :certifi.cacerts(),
            certfile: "/srv/erlang/lib/network_led-0.1.0/priv/testdev01.cert",
            keyfile: "/srv/erlang/lib/network_led-0.1.0/priv/testdev01.private.key",
            depth: 99,
            host: 'axxxxxxxxxx-ats.iot.eu-central-1.amazonaws.com',
            port: 8883,
            customize_hostname_check: [match_fun: :public_key.pkix_verify_hostname_match_fun(:https)],
            versions: [:'tlsv1.2'],
            server_name_indication: '*.iot.eu-central-1.amazonaws.com',
            },
            subscriptions: [{"#", 0}]
        ]
        Tortoise.Connection.start_link(client_opts)
        Tortoise.publish("testdev01", "sensor/test", "hello")

When I insert some "debug console log's" between the functions, I can see that it runs until publish, then it hangs.
I believe this happened before in #62 #95
Nobody tackled this problem for 2 years?
I'm using Nerves, Elixir 1.11.2-otp-23, erlang 23.1.4
Any help appreciated, thanks!

Update: When I remove the depth option, error is thrown.
Fatal - Handshake Failure\n {bad_cert,max_path_length_reached}'}}

Update 2: I switched the certifi with Amazon Root CA1 I found from here but it gives Unknown CA error now. I guess I need the full chain to verify it? I appended an intermediate cert from https://good.sca1a.amazontrust.com/ here to the same pem file but the result is the same, unknown CA.

@MAkcanca MAkcanca changed the title AWS IoT and publish freeze AWS IoT and publish freeze on Nerves Nov 29, 2020
@dunyakirkali
Copy link

@MAkcanca How did you solve this at the end?

@MAkcanca
Copy link
Author

@dunyakirkali They forgot about this issue, probably not in their scope. I ended up not using nerves, currently trying to reach out to some Japanese folks about this. If you do solve this however, please ping me here.

@MAkcanca MAkcanca reopened this Mar 21, 2021
@taun
Copy link

taun commented Sep 6, 2021

I just had this or an issue with the same symptoms. It was due to not specifying a timeout option and so the call was never returning or timing out.

Tortoise.publish("testdev01", "sensor/test", "hello", dos: 0, timeout: 500)

Returns after 500mS with a clause matching error due to {:error, :timeout} not being handled. But that's progress compared to hanging.

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

3 participants