question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the bug

Is this a bug? Of not supported? I am trying to connect to AWS IoT with client certificate over port 8883. I see some references to ALPN but that doesn’t seem a hard requirement. But I couldn’t find anyway to configure ALPN as well, so that might be related.

Which project is your bug related to?

  • Client

Details

I checked that the certificates are valid by using “openssl s_client -CAfile ca.pem -cert client.pem -key client.key -connect your-endpoint.amazonaws.com:8883”. Also, I catch the certificate errors in MQTTnet so that all seems fine. But when I try a ConnectAsync, this is the error I receive: “MQTTnet.Exceptions.MqttCommunicationTimedOutException’ was thrown”.

MQTTnet.Exceptions.MqttCommunicationTimedOutException
  HResult=0x80131500
  Message=Exception of type 'MQTTnet.Exceptions.MqttCommunicationTimedOutException' was thrown.
  Source=mscorlib
  StackTrace:
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MQTTnet.PacketDispatcher.MqttPacketAwaiter`1.<WaitOneAsync>d__4.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MQTTnet.Client.MqttClient.<SendAndReceiveAsync>d__50`1.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MQTTnet.Client.MqttClient.<AuthenticateAsync>d__44.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at MQTTnet.Client.MqttClient.<ConnectAsync>d__35.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MQTTnet.Client.MqttClient.<ConnectAsync>d__35.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at MyProgram.MyProg.PD() in MyProgram.vb:line 577
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:27

github_iconTop GitHub Comments

1reaction
Chef904commented, Mar 17, 2021

Hi, i am not able to connect with AWS IoT over TLS. Is there anywhere an complete code example with MQTTnet? With M2Mqtt i got an successful connectien.

1reaction
nicolasr75commented, Oct 8, 2020

For others trying this I would like to mention two pitfalls that at first prevented me from publishing messages. Quoted from the AWS IoT docs:

AWS IoT supports MQTT quality of service (QoS) levels 0 and 1 only. AWS IoT doesn’t support publishing or subscribing with QoS level 2. When QoS level 2 is requested, the message broker doesn’t send a PUBACK or SUBACK.

The MQTT specification provides a provision for the publisher to request that the broker retain the last message sent to a topic and send it to all future topic subscribers. AWS IoT doesn’t support retained messages. If a request is made to retain messages, the connection is disconnected.

Meaning, don’t use .WithExactlyOnceQoS(), .WithRetainFlag()

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Support and Customer Service Contact Info - Amazon.com
On this page, you'll find info regarding the different ways to get in touch with AWS support, including Sales, Technical, Compliance, and Login...
Read more >
Purchase AWS Premium Customer Support Plans
AWS Support provides a mix of tools and technology, people, and programs designed to proactively help you optimize performance, lower costs, and innovate ......
Read more >
Getting started with AWS Support
Use AWS Support to create and manage cases, troubleshoot issues, and access services such as AWS Trusted Advisor.
Read more >
AWS Support Plan Comparison | Developer, Business ...
Learn about the variety of Support plans AWS offers to fit your needs. Plans include a mix of technical support with fast response...
Read more >
Pricing for AWS Support Plans | Starting at $29 Per Month
AWS Support fees are calculated on a per-account basis for Business and Developer Support plans. For Enterprise On-Ramp and Enterprise Support, you are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found