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

ABP Application Working on local but not working on IIS #17339

Closed
cgdif opened this issue Aug 10, 2023 · 43 comments
Closed

ABP Application Working on local but not working on IIS #17339

cgdif opened this issue Aug 10, 2023 · 43 comments

Comments

@cgdif
Copy link

cgdif commented Aug 10, 2023

Documentation

Please check the official documentation before asking questions: https://docs.abp.io

GitHub Issues

GitHub issues are for bug reports, feature requests, and other discussions about the framework.

If you're creating a bug/problem report, please include the followings:

  • ABP CLI 7.3.1.
  • User interface Angular
  • Database provider EF Core
  • Exception message and stack trace if available (check the logs).
  • Steps needed to reproduce the problem.

Please Application is working fine on localhost, but the APIs are not working when hosted on IIS.

appsettings.json
{ "App": { "SelfUrl": "https://192.168.0.187:44352", "ClientUrl": "http://192.168.0.187:4200", "CorsOrigins": "http://192.168.0.187:4200,https://192.168.0.187,https://192.168.0.187:*,https://*.dbt.com,http://localhost:4435,http://localhost:85,http://localhost:4200,127.0.0.1:80,https://localhost:44352,http://localhost:50278/,http://localhost:80,https://localhost:80", "RedirectAllowedUrls": "https://192.168.0.187:44352,http://192.168.0.187:4200,http://192.168.0.187:*/*,http://192.168.0.187:*/*,http://localhost:4200,https://localhost:44389,https://localhost:44352" }, "ConnectionStrings": { // "Default": "Server=tcp:dbcgdbt.database.windows.net,1433;Initial Catalog=cgdbt-db;Persist Security Info=False;User ID=difadmin;Password=Chhattisgarh.dif@123;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" "Default": "Server=(localdb)\\MSSQLLocalDB;Database=cgdbt;Trusted_Connection=True;MultipleActiveResultSets=true" }, "AuthServer": { "Authority": "https://192.168.0.187:44352", "RequireHttpsMetadata": "false", "SwaggerClientId": "dbt_Swagger" }, "StringEncryption": { "DefaultPassPhrase": "########" }, "Settings": { "IsSelfRegistrationEnabled": false, "Abp.Account.IsSelfRegistrationEnabled": false } }

DBMigrator>appsettings.json
{ "ConnectionStrings": { // "Default": "Server=tcp:dbcgdbt.database.windows.net,1433;Initial Catalog=cgdbt-db;Persist Security Info=False;User ID=difadmin;Password=Chhattisgarh.dif@123;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" "Default": "Server=(localdb)\\MSSQLLocalDB;Database=cgdbt;Trusted_Connection=True;MultipleActiveResultSets=true" }, "OpenIddict": { "Applications": { "dbt_Web": { "ClientId": "dbt_Web", "ClientSecret": "1q2w3e*", "RootUrl": "https://192.168.0.187:44325" }, "dbt_App": { "ClientId": "dbt_App", "RootUrl": "http://192.168.0.187:4200" }, "dbt_BlazorServerTiered": { "ClientId": "dbt_BlazorServerTiered", "ClientSecret": "1q2w3e*", "RootUrl": "https://192.168.0.187:44318" }, "dbt_Swagger": { "ClientId": "dbt_Swagger", "RootUrl": "https://192.168.0.187:44352/" } } } }

Launch settings:
{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "https://localhost:44352", "sslPort": 44352 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, "chhattisgarh.dbt.HttpApi.Host": { "commandName": "Project", "launchBrowser": true, "applicationUrl": "https://0.0.0.0:44352", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } }

updated entries in local DB under OpenIddictApplications table.

Stack Overflow

Please use Stack Overflow for your questions about using the framework, templates, and samples:

https://stackoverflow.com/questions/tagged/abp

Use abp tag in your questions.

@cgdif
Copy link
Author

cgdif commented Aug 10, 2023

@maliming
Copy link
Member

hi

You can try to get a valid HTTPS certificate and it seems more like a environment.

image

@maliming
Copy link
Member

If there is an error you can check the Logs.txt file.

@Keertesh
Copy link

If possible shall we get on a call.

@Keertesh
Copy link

Shall I use the self sign certificate. As the domain purchasing will happen once the portal will start working on iis.

@gterdem
Copy link
Contributor

gterdem commented Aug 10, 2023

Yes, you can use self signed certificate.

@cgdif
Copy link
Author

cgdif commented Aug 12, 2023

@maliming getting following error on log.txt while hosting on IIS

log.txt output:
`2023-08-12 22:48:29.344 +05:30 [INF] Request starting HTTP/1.1 GET https://localhost:44352/ - -
2023-08-12 22:48:31.141 +05:30 [ERR] An error occurred using the connection to database 'cgdbt' on server '(localdb)\MSSQLLocalDB'.
2023-08-12 22:48:31.165 +05:30 [ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.SettingManagement.EntityFrameworkCore.SettingManagementDbContext'.
...
...
...

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "cgdbt" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\SYSTEM'.
`

@maliming
Copy link
Member

Cannot open database "cgdbt" requested by the login. The login failed.

check the database to see if it exists.

@Keertesh
Copy link

Database exists as it is working when running it from visual studio. This is happening when running the application from iis by putting the published folder in a folder.

@maliming
Copy link
Member

You can use sql server sa and password in your connection string.

@cgdif
Copy link
Author

cgdif commented Aug 13, 2023

You can use sql server sa and password in your connection string.

connectiong string used on IIS :
Server=(localdb)\MSSQLLocalDB;Database=cgdbt;User ID=sa;Password=●●●●●●●;MultipleActiveResultSets=true;Encrypt=False;TrustServerCertificate=true;Integrated Security=true

attaching the log.txt here:

@maliming
Copy link
Member

Please remove Integrated Security=true from the connection string.

@cgdif
Copy link
Author

cgdif commented Aug 13, 2023

Please remove Integrated Security=true from the connection string.

updated connection string removed Integrated Security=true.
Server=(localdb)\\MSSQLLocalDB;Database=cgdbt;User ID=sa;Password=●●●●●●●;MultipleActiveResultSets=true;Encrypt=False;TrustServerCertificate=true

please find the updated log.txt

@maliming
Copy link
Member

hi @cgdif

Login failed for user 'sa'.

This is an code problem. You can check the errors in the logs.txt.

@cgdif
Copy link
Author

cgdif commented Aug 13, 2023

hi @cgdif

Login failed for user 'sa'.

This is a code problem. You can check the errors in the logs.txt.

I checked the logs and tried multiple solutions, but the application is not working on IIS at all, last connection string I tried was.
"Server=(localdb)\MSSQLLocalDB;Database=cgdbt;User ID=sa;Password=*****;Trusted_Connection=False;"
It would be great if you can look into this once. As the .Net Core application is not working on IIS.

@cgdif
Copy link
Author

cgdif commented Aug 13, 2023

The same setup is working on IIS Express

@maliming
Copy link
Member

How can I reproduce this?

Can you try without localdb?

@Keertesh
Copy link

Keertesh commented Aug 14, 2023

The steps I followed were:
Run the application on local.

Published to a local folder.

Create a site and app pool on IIS Keep the published folder as IIS Physical path. Other settings are Local System, No managed code.

Then added 44352 with all unassigned ips in the managed binding.

Added connection string in IIS

Start the application and browse.

@maliming
Copy link
Member

Added connection string in IIS

The connection string should be exiting in the appsettings.json file.

@Keertesh
Copy link

Keertesh commented Aug 14, 2023

Yes, keeping the connection string in sync in all the places including the appsettings.json file.

@maliming
Copy link
Member

Published to a local folder.

You can also run the app in the publish folder by dotnet yourapp.dll command.

If this work that's mean there is a problem with IIS. and I have no idea about IIS.

@Keertesh
Copy link

I clicked the .exe on the published folder then the application was running. Although it was running on localhost with port 5000 is there a way to run it on System IP from the published folder without IIS.

@Keertesh
Copy link

The problem is when I run the application on IP from the launch settings on visual studio and run the angular UI from IIS the UI is not able the access the API.

@Keertesh
Copy link

Thanks for sharing the urls, let me try this.

@cgdif
Copy link
Author

cgdif commented Aug 14, 2023

HI @maliming, I'm running the UI (Angular) from IIS and API using dotnet run --urls "http://192.168.29.86:44352" this command but the UI is not able to access the API.

abp api
abp ui

@maliming
Copy link
Member

Your SSL certificate is invalid.

@cgdif
Copy link
Author

cgdif commented Aug 14, 2023

Your SSL certificate is invalid.

okay, this same setup works when I run using ng serve --host="IP", please share the url if you have access to bind the self-sign certificate. I generated a self-sign certificate, but it is not showing up while running even when I've imported it and installed it. (Using mmc and IIS)

@maliming
Copy link
Member

This is nothing to do with abp. You can get an SSL certificate and set it correctly.

Or you can use localhost and port as your domain names.

#17339 (comment)

https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-7.0&tabs=visual-studio%2Clinux-ubuntu#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos

@Keertesh
Copy link

UI started working on IIS by changing the hostname to localhost. I need to get a ssl for other domains. Thanks @maliming.

@Keertesh
Copy link

Application keep on loading even after removing the ssl. When running on LAN and accessing over network.

@maliming
Copy link
Member

hi @Keertesh

Check your application logs.

@cgdif
Copy link
Author

cgdif commented Aug 22, 2023

hi @Keertesh

Check your application logs.

2023-08-22 13:15:44.004 +05:30 [ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.OpenIddict.EntityFrameworkCore.OpenIddictDbContext'.
System.Threading.Tasks.TaskCanceledException: A task was canceled.

@maliming
Copy link
Member

The full logs.

@cgdif
Copy link
Author

cgdif commented Aug 22, 2023

An exception occurred while iterating over the results of a query for context type 'Volo.Abp.OpenIddict.EntityFrameworkCore.OpenIddictDbContext'.
System.Threading.Tasks.TaskCanceledException: A task was canceled.

logs.txt

@maliming
Copy link
Member

Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'commens'.

It seems your migrations file is not up to date. Please check it.

@cgdif
Copy link
Author

cgdif commented Aug 22, 2023

Invalid column name 'commens

logs are further down I updated the migration, but the issue persists. getting token has expired, error validating the token in the Ui console.

-- also please suggest on changing the default UI url from http://10.132.29.185 to http://10.132.29.185/abc

@maliming
Copy link
Member

You can also check the logs from your SQL server.

@cgdif
Copy link
Author

cgdif commented Aug 24, 2023

You can also check the logs from your SQL server.

@maliming When I'm login then I'm getting angular-oauth2-oidc.mjs token has expired, it is working fine on the system it is hosted. But when I'm accessing it on a system connected via LAN it is throwing the above error and the screen is stuck on Login and keep on calling the below API. Please suggest as the rest of the parts are working fine on the system it is hosted.
http://10.132.29.185/dbt?code=C_pEjz6f1aLePUUztuiAINKwNfFmJk2cw_s4_8IjLlE&state=cnlLOWRCRkZBTkF3ZnpTa2RFcWFtQldlbXo2U2YuUmRHUUs2ODlDc1ZDbC5n

I saw this in the logs:
[12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateToken.

Please suggest.

Error log
[12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ApplyTokenResponseContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ProcessJsonResponse1[[OpenIddict.Server.OpenIddictServerEvents+ApplyTokenResponseContext, OpenIddict.Server, Version=3.1.1.0, Culture=neutral, PublicKeyToken=35a561290d20de2f]]. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ApplyTokenResponseContext was marked as handled by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ProcessJsonResponse1[[OpenIddict.Server.OpenIddictServerEvents+ApplyTokenResponseContext, OpenIddict.Server, Version=3.1.1.0, Culture=neutral, PublicKeyToken=35a561290d20de2f]]. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessSignInContext was successfully processed by OpenIddict.Server.OpenIddictServerHandlers+Exchange+ApplyTokenResponse1[[OpenIddict.Server.OpenIddictServerEvents+ProcessSignInContext, OpenIddict.Server, Version=3.1.1.0, Culture=neutral, PublicKeyToken=35a561290d20de2f]]. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessSignInContext was marked as handled by OpenIddict.Server.OpenIddictServerHandlers+Exchange+ApplyTokenResponse1[[OpenIddict.Server.OpenIddictServerEvents+ProcessSignInContext, OpenIddict.Server, Version=3.1.1.0, Culture=neutral, PublicKeyToken=35a561290d20de2f]]. [12:50:06 INF] Executed action Volo.Abp.OpenIddict.Controllers.TokenController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) in 89.795ms [12:50:06 INF] Executed endpoint 'Volo.Abp.OpenIddict.Controllers.TokenController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore)' [12:50:06 DBG] Added 0 entity changes to the current audit log [12:50:06 DBG] Added 0 entity changes to the current audit log [12:50:06 DBG] Added 0 entity changes to the current audit log [12:50:06 DBG] Added 0 entity changes to the current audit log [12:50:06 INF] Request finished HTTP/1.1 POST http://10.132.29.190/connect/token application/x-www-form-urlencoded 224 - 200 6009 application/json;charset=UTF-8 114.9607ms [12:50:06 INF] Request starting HTTP/1.1 GET http://10.132.29.190/api/abp/application-configuration - - [12:50:06 INF] Request starting HTTP/1.1 GET http://10.132.29.190/api/abp/application-configuration - - [12:50:06 INF] CORS policy execution successful. [12:50:06 INF] CORS policy execution successful. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessRequestContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+InferIssuerFromHost. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessRequestContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+InferIssuerFromHost. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+InferEndpointType. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+InferEndpointType. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+InferIssuerFromHost. [12:50:06 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+InferIssuerFromHost. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromAuthorizationHeader. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromAuthorizationHeader. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromBodyForm. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromBodyForm. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromQueryString. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromQueryString. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateToken. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateToken. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateToken. [12:50:06 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateToken. [12:50:06 DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated. [12:50:06 DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated. [12:50:06 INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)' [12:50:06 INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)' [12:50:06 INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature

@Keertesh
Copy link

Keertesh commented Aug 24, 2023

@maliming @gterdem How to add api prefix in the url.

after the ip or host name

@cgdif
Copy link
Author

cgdif commented Aug 25, 2023

getting this on IIS, Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call

@cgdif
Copy link
Author

cgdif commented Aug 25, 2023

An exception occurred while iterating over the results of a query for context type 'Volo.Abp.BackgroundJobs.EntityFrameworkCore.BackgroundJobsDbContext'

@cgdif
Copy link
Author

cgdif commented Aug 25, 2023

---> Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)

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

4 participants