Open Closed

Maui Blazor (Hybrid) App - Mobile Application Won't Start Without .HttpApi.Host project Running #7970


User avatar
0
DWaterfield created
  • Template: app
  • Created ABP Studio Version: 0.8.2
  • Tiered: No
  • UI Framework: maui-blazor
  • Theme: leptonx
  • Theme Style: system
  • Database Provider: ef
  • Database Management System: sqlserver
  • Separate Tenant Schema: No
  • Mobile Framework: maui
  • Public Website: No
  • Optional Modules:
    • GDPR
    • FileManagement
    • TextTemplateManagement
    • LanguageManagement
    • AuditLogging
    • SaaS
    • OpenIddictAdmin
  • Exception message and full stack trace:

  • Steps to reproduce the issue: We're using the default MAU Blazor (Hybrid) template as created via ABP Studio, and have added the "Login workaround" code as provided here [Maui Blazor (Hybrid) App Can't Login #7908](https://abp.io/support/questions/7908/Maui-Blazor-Hybrid-App-Can%27t-Login)

The solution name is Handheld When the "Server" project Handheld.HttpApi.Host is running and the mobile app Handheld.MauiBlazor is deployed and running on an Android emulator, all works as expected, however when the "Server" project is not running (to simulate the mobile device not having connectivity to the server), the mobile app Handheld.MauiBlazor does not start and throws the above exception in MauiProgram.cs

The reason we're testing this is that the mobile application needs to be able to work when it has no Internet Connectivity as it will be used to take photos as part of vehicle inspections, some of which take place at airfields or ports where Internet connectivity is not always available.

While we realise that none of the "Server" functionality would be accessible via the APIs in the Handheld.HttpApi.Host, we were hoping to be able to test for Network Connectivity using the normal MAUI libraries e.g. Connectivity and switch functionality on/off as appropriate.

The client project (Handheld.MauiBlazor) that is deployed to the mobile device though, appears to perform a lot of calls to the server as part of its "startup code".

Q. As a mobile app that won't start unless it has full internet connectivity is not going to be practicable for us, how might we utilise the ABP Studio MAUI (Blazor Hybrid) template / libraries to achieve this?


8 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi,

    You told you are working on Android. Did you forward your local machine port to the emulator by following Port mapping step from the documentation?

    https://abp.io/docs/latest/framework/ui/maui?Tiered=No#android

    As an example:

    adb reverse tcp:44305 tcp:44305
    

    44305 should be your HttpApi.Host port

  • User Avatar
    0
    DWaterfield created

    Hi,

    Yes we did the adb step, which in our case is

    adb reverse tcp:44358 tcp:44358
    

    I didn't write down each specific step as in our previous question Login question in order to keep the question clear, but it is the same Solution.

    I mentioned that we have liangshiwei's workaround code in place in case it is relevant, but the startup behaviour is the same without that workaround code in place.

    With the server project (Handheld.HttpApi.Host) running we have a functioning app and we can even Login due to the workaround code.

    When the server project is running......... If we put a breakpoint on line 36 (see screenshot in the question) and then execute that line, we see the following in the console output window of the server (Handheld.HttpApi.Host) project

    The red outlined section is what happens as line 36 is executed, with the yellow section appearing to show calls to the server e.g.

    [INF] Request finished HTTP/1.1 GET https://localhost:44358/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - 200 null application/json; charset=utf-8 75.7252ms 2024-09-26 10:56:15.896 +01:00 [INF] Request starting HTTP/1.1 GET https://localhost:44358/api/abp/application-localization?CultureName=en&OnlyDynamics=True&api-version=1.0 - null null

    which is why we suspect that when the deployed mobile project (Handheld.MauiBlazor) cannot contact the server (as might be the case for a mobile application), these calls fail and the application cannot startup?

  • User Avatar
    0
    improwise created

    Unless things have changed very recently, we can confirm seeing the same problem, app would not run without the backend available. In our case, that was not a problem so we never bothered to investigate it further. This is true also with the app deployed to my Android with the backend i Azure stopped.

  • User Avatar
    0
    DWaterfield created

    Thank you for the confirmation.

    While we understand that the abp libraries both open source and commercial should be platform agnostic and shouldn't have to care about high level issues like connectivity, it seems like unfortunately, the "disconnected scenario" has not been considered for the overall ABP Maui Blazor Hybrid project template?

    Which leaves us in a tricky situation as we seemingly can't use ABP to create the mobile client of our Application?

    Q. Could we please get a view from the ABP Architect/Designers whether that is the actual current situation and whether/if the ABP templates are likely to deal with the disconnected scenario in the near future?

    If that isn't likely to happen in the very near future or not at all, then we still have a project to start which leaves us with the option of using the Microsoft projects templates i.e. for the mobile part, and getting some use out of the ABP Product by utilising the ABP server side parts.

    Q. Presumably we could call all the existing ABP endpoints that we see via Swagger on the Handheld.HttpApi.Host project and get some use from the ABP libraries?

    We're not sure if that means removing these parts from the Solution

    or... Q. whether it would be cleaner to just create an ABP Blazor Server App so we'd still have our GUI for administering Users, setting up Tenants, viewing Audit Logs etc. and call into the nnnnHttpApi.Host via the Swagger endpoints from a Visual Studio generated ".NET MAUI Blazor Hybrid and Web App" which would startup in the disconnected state and we could also detect when we have connectivity and call our server side logic through the abp/api endpoints when required?

  • User Avatar
    0
    improwise created

    Honestly, not due to ABP but we have given up on MAUI for now even tough we are .NET people. Would really like to use it though if/once it becomes ready for prime time including tooling that does not break as soon as you try to install Firebase packages etc. The dream to finally get rid of JS continues to be a dream but one day :)

    But that is probably another discussion, but that is the main reason we did not continue trying to get it to work properly with ABP. I hope you manage to get it sorted for your needs.

  • User Avatar
    0
    DWaterfield created

    Honestly, not due to ABP but we have given up on MAUI for now even tough we are .NET people. Would really like to use it though if/once it becomes ready for prime time including tooling that does not break as soon as you try to install Firebase packages etc. The dream to finally get rid of JS continues to be a dream but one day :)

    But that is probably another discussion, but that is the main reason we did not continue trying to get it to work properly with ABP. I hope you manage to get it sorted for your needs.

    Thanks for the heads up, we've had great success with Blazor Server and the ABP libraries that utilise that architecture, with the rapid development due to not having to duplicate all dto's in C# and javascript and the magic SignalR connection between server and browser, but our mobile journey is just beginning.

    We seem to have hit a very large brick wall at the moment, and we really want to utilise HTML, CSS and razor pages rather than .XAML......but we shall have to see how this all ends up!

  • User Avatar
    0
    improwise created

    Honestly, not due to ABP but we have given up on MAUI for now even tough we are .NET people. Would really like to use it though if/once it becomes ready for prime time including tooling that does not break as soon as you try to install Firebase packages etc. The dream to finally get rid of JS continues to be a dream but one day :)

    But that is probably another discussion, but that is the main reason we did not continue trying to get it to work properly with ABP. I hope you manage to get it sorted for your needs.

    Thanks for the heads up, we've had great success with Blazor Server and the ABP libraries that utilise that architecture, with the rapid development due to not having to duplicate all dto's in C# and javascript and the magic SignalR connection between server and browser, but our mobile journey is just beginning.

    We seem to have hit a very large brick wall at the moment, and we really want to utilise HTML, CSS and razor pages rather than .XAML......but we shall have to see how this all ends up!

    Xamarin Forms AFAIK is EOF now so it's all MAUI. Don't think that neither ABP nor Blazor is the main problem here for the time being. Would be really nice to be able to reuse Blazor though all the way.

  • User Avatar
    0
    DWaterfield created

    ... Xamarin Forms AFAIK is EOF now so it's all MAUI. Don't think that neither ABP nor Blazor is the main problem here for the time being. Would be really nice to be able to reuse Blazor though all the way.

    We agree, .Net MAUI has replaced Xamarin.

    We're interested in the MAUI Blazor Hybrid model (which our understanding is that its a Blazor webview control running natively inside a mobile device under .Net MAUI) because it lets us utilise our decades of HTML, .css etc. knowledge rather than having to use .XAML which came in with Silverlight / WPF IIRC, and we can still access the mobile hardware such as the camera etc. while developing in C#

    Our immediate roadblock is that its looking like the ABP template was not designed to work in the scenario where the mobile device does not have 100% connectivity!

    We'll have to see what the ABP architects/designers say re my questions to decide what direction / solution we end up with!

Made with ❤️ on ABP v9.0.0-preview Updated on September 27, 2024, 06:34