I was calling the connect function from OnStart()
method of App.xaml.cs
like below:
protected override async void OnStart()
{
try
{
base.OnStart();
await MqttService.Instance.ConnectAsync();
}
catch (Exception exception)
{
Utility.SendCrashReport(exception);
}
}
The issue here is related to calling an async method (ConnectAsync) from OnStart, which does not support await properly in .NET MAUI.
App.OnStart() is not truly asynchronous — it's a void method, and calling await inside it doesn't work reliably.
This can cause exceptions to be swallowed silently or result in undefined behavior like the method never being hit.
I have resolved this issue by calling the connect function from home page constructor.