从 mac 开发 machine 将具有多个项目的 .Net 6 应用程序部署到 Linux Elastic Beanstalk 服务器
Deploy .Net 6 app with multiple projects to Linux Elastic Beanstalk Server from mac development machine
我正在尝试将具有多个项目的 .Net 6 应用程序部署到 Linux 来自 mac 开发 machine 的 Elastic Beanstalk 服务器。 api 部署后,我无法查询它。我已经通过 2 种方式完成了 - Just an EC2 instance by following this tutorial, just using command line,以及通过 Elastic beantalk 控制台。所以我有 2 个 EC2 实例。他们都说自己是运行ning.
该项目有一个 Asp.Net 应用程序 (Vepo.Web) 和 5 个用于应用层的辅助项目。 “Vepo”项目只是我制作的一个占位符,因为互联网告诉我当你命名你的 dll 与你的解决方案不同时存在错误;解决方案是“Vepo.sln”。
发布创建的文件如下所示:
我通过 cd 获得了要部署到我的 asp.net 核心网络应用程序 (Vepo.Web) 的源代码,然后 运行 dotnet publish -r linux-x64 --self-contained false --output build
,然后转到“Vepo. Web/build”在取景器中。然后select所有文件>右键>压缩(不要压缩父文件夹!)。这会创建“archive.zip”。然后在 Elastic Beanstalk 控制台中上传“archive.zip”。现在它看起来像这样:
但是我好像查询不到api。在 Postman 中,我正在尝试:
ec2-54-xxx-xxx-95.ap-东南-2.compute.amazonaws.com:5001/用户
但我得到:
Error: connect ECONNREFUSED 54.xxx.xxx.95:5000
导航到它给我:
我创建了这些入站规则以允许任何人进入,因为我拼命想进入:
有人可以帮助我在没有获得 404/401 的情况下访问我的网络 API 中的端点吗?如果我遗漏了什么,我会提供任何需要的信息。
更新:我猜当我 ssh 进入应用程序并 运行 这个命令时,应用程序正在 运行ning(不知道如何从邮递员或我的应用程序访问它,在浏览器中访问它不起作用 https://ec2-54-xxx-xxx-53.ap-southeast-2.compute.amazonaws.com:5001/fashionitems/search?searchTerm=B¤tPage=1&pageSize=10):
ubuntu@ip-172-31-44-141:~/app$ ./Vepo.Web —urls http://+:5000 —environment Development
warn: Microsoft.EntityFrameworkCore.Model.Validation[10400]
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
warn: 02/27/2022 03:25:03.441 CoreEventId.SensitiveDataLoggingEnabledWarning[10400] (Microsoft.EntityFrameworkCore.Infrastructure)
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'VeganItem.Tags' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: 02/27/2022 03:25:03.455 CoreEventId.CollectionWithoutComparer[10620] (Microsoft.EntityFrameworkCore.Model.Validation)
The property 'VeganItem.Tags' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
info: 02/27/2022 03:25:03.716 CoreEventId.ContextInitialized[10403] (Microsoft.EntityFrameworkCore.Infrastructure)
Entity Framework Core 6.0.0 initialized 'VepoContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL:6.0.0+025fc55189ae41e3f2b98bcbe4eb44c505653700' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled using NetTopologySuite
dbug: 02/27/2022 03:25:05.976 CoreEventId.QueryCompilationStarting[10111] (Microsoft.EntityFrameworkCore.Query)
Compiling query expression:
'DbSet<VeganItem>()'
dbug: 02/27/2022 03:25:06.200 CoreEventId.QueryExecutionPlanned[10107] (Microsoft.EntityFrameworkCore.Query)
Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<VeganItem>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
EmptyProjectionMember -> Dictionary<IProperty, int> { [Property: VeganItem.Id (int) Required PK AfterSave:Throw ValueGenerated.OnAdd, 0], [Property: VeganItem.CompanyName (string) Required Index MaxLength(256), 1], [Property: VeganItem.CreatedById (string) FK Index MaxLength(256), 2], [Property: VeganItem.CreatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 3], [Property: VeganItem.Description (string) MaxLength(256), 4], [Property: VeganItem.Discriminator (string) Required Index AfterSave:Throw MaxLength(256), 5], [Property: VeganItem.Images (List<string>) MaxLength(10), 6], [Property: VeganItem.IsNotVeganCount (int) Required, 7], [Property: VeganItem.IsVeganCount (int) Required, 8], [Property: VeganItem.Name (string) Required Index MaxLength(256), 9], [Property: VeganItem.Rating (int) Required, 10], [Property: VeganItem.RatingsCount (int) Required, 11], [Property: VeganItem.Tags (List<Option>), 12], [Property: VeganItem.UpdatedById (string) FK Index MaxLength(256), 13], [Property: VeganItem.UpdatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 14], [Property: EventItem.LocationName (string) Required Index MaxLength(256), 15], [Property: FashionItem.Age (Option) Required, 16], [Property: FashionItem.Gender (Option) Required, 17], [Property: RecipeItem.CookTime (TimeSpan) Required, 18], [Property: RecipeItem.Difficulty (Option) Required, 19], [Property: RecipeItem.Ingredients (List<string>) Required MaxLength(100), 20], [Property: RecipeItem.Method (List<string>) Required MaxLength(100), 21], [Property: RecipeItem.PrepTime (TimeSpan) Required, 22], [Property: RecipeItem.ServesCount (int) Required, 23], [Property: RecipeItem.Tips (List<string>) MaxLength(2), 24] }
SELECT v.Id, v.CompanyName, v.CreatedById, v.CreatedDate, v.Description, v.Discriminator, v.Images, v.IsNotVeganCount, v.IsVeganCount, v.Name, v.Rating, v.RatingsCount, v.Tags, v.UpdatedById, v.UpdatedDate, v.LocationName, v.Age, v.Gender, v.CookTime, v.Difficulty, v.Ingredients, v.Method, v.PrepTime, v.ServesCount, v.Tips
FROM VeganItems AS v),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, VeganItem>,
Vepo.DataContext.VepoContext,
False,
True,
True
)'
dbug: 02/27/2022 03:25:06.262 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:06.267 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (34ms).
dbug: 02/27/2022 03:25:06.270 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.464 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.469 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
info: 02/27/2022 03:25:06.546 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (77ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
dbug: 02/27/2022 03:25:06.629 CoreEventId.StartedTracking[10806] (Microsoft.EntityFrameworkCore.ChangeTracking)
Context 'VepoContext' started tracking 'MenuItem' entity with key '{Id: 1}'.
dbug: 02/27/2022 03:25:06.687 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:06.689 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.693 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:06.694 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.695 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
info: 02/27/2022 03:25:06.697 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
dbug: 02/27/2022 03:25:06.698 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:06.698 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.698 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.201 CoreEventId.QueryCompilationStarting[10111] (Microsoft.EntityFrameworkCore.Query)
Compiling query expression:
'DbSet<VeganItemEstablishment>()'
dbug: 02/27/2022 03:25:07.232 CoreEventId.QueryExecutionPlanned[10107] (Microsoft.EntityFrameworkCore.Query)
Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<VeganItemEstablishment>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
EmptyProjectionMember -> Dictionary<IProperty, int> { [Property: VeganItemEstablishment.Id (int) Required PK AfterSave:Throw ValueGenerated.OnAdd, 0], [Property: VeganItemEstablishment.CreatedById (string) FK Index MaxLength(256), 1], [Property: VeganItemEstablishment.CreatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 2], [Property: VeganItemEstablishment.Discriminator (string) Required AfterSave:Throw MaxLength(256), 3], [Property: VeganItemEstablishment.EstablishmentId (int?) FK Index, 4], [Property: VeganItemEstablishment.InEstablishmentCount (int) Required, 5], [Property: VeganItemEstablishment.NotInEstablishmentCount (int) Required, 6], [Property: VeganItemEstablishment.Price (double) Required, 7], [Property: VeganItemEstablishment.UpdatedById (string) FK Index MaxLength(256), 8], [Property: VeganItemEstablishment.UpdatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 9], [Property: VeganItemEstablishment.VeganItemId (int) Required FK Index, 10], [Property: EventItemEstablishment.Dates (List<NpgsqlRange<DateTime>>) Required MaxLength(10), 11] }
SELECT v.Id, v.CreatedById, v.CreatedDate, v.Discriminator, v.EstablishmentId, v.InEstablishmentCount, v.NotInEstablishmentCount, v.Price, v.UpdatedById, v.UpdatedDate, v.VeganItemId, v.Dates
FROM VeganItemEstablishments AS v),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, VeganItemEstablishment>,
Vepo.DataContext.VepoContext,
False,
True,
True
)'
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:07.233 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
info: 02/27/2022 03:25:07.238 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
dbug: 02/27/2022 03:25:07.243 CoreEventId.StartedTracking[10806] (Microsoft.EntityFrameworkCore.ChangeTracking)
Context 'VepoContext' started tracking 'MenuItemEstablishment' entity with key '{Id: 1}'.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:07.291 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
info: 02/27/2022 03:25:07.293 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
dbug: 02/27/2022 03:25:07.293 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:07.294 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.294 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.407 CoreEventId.ContextDisposed[10407] (Microsoft.EntityFrameworkCore.Infrastructure)
'VepoContext' disposed.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/ubuntu/app
P.S。我更喜欢控制台,我是一个 gui 人,宁愿用 AWS 控制台解决这个问题。
这个浏览器消息好点了吗?听起来有点像它存在,但我需要提供 auth/key:
我在 elastic beanstalk 上重新部署并获得了这些日志:
Mar 1 05:55:49 ip-172-31-2-81 web: Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
Mar 1 05:55:49 ip-172-31-2-81 web: SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
Mar 1 05:55:49 ip-172-31-2-81 web: FROM "VeganItemEstablishments" AS v
Mar 1 05:55:49 ip-172-31-2-81 web: info: 3/1/2022 05:55:49.622 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Mar 1 05:55:49 ip-172-31-2-81 web: Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
Mar 1 05:55:49 ip-172-31-2-81 web: SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
Mar 1 05:55:49 ip-172-31-2-81 web: FROM "VeganItemEstablishments" AS v
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
Mar 1 05:55:49 ip-172-31-2-81 web: A data reader was disposed.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Mar 1 05:55:49 ip-172-31-2-81 web: Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Mar 1 05:55:49 ip-172-31-2-81 web: Closed connection to database 'vepo_admin' on server ''.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.714 CoreEventId.ContextDisposed[10407] (Microsoft.EntityFrameworkCore.Infrastructure)
Mar 1 05:55:49 ip-172-31-2-81 web: 'VepoContext' disposed.
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[14]
Mar 1 05:55:49 ip-172-31-2-81 web: Now listening on: http://localhost:5000
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Application started. Press Ctrl+C to shut down.
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Hosting environment: Production
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Content root path: /var/app/current
我猜似乎错误的关键是“正在监听:http://localhost:5000”(那不应该是我的 ec2 实例 public ipv4 地址吗?)和“托管环境:生产“因为我只能确认开发环境正常工作,所以我现在将尝试 运行 在生产版本中本地化。
按照接受的答案添加后,它起作用了。:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://*:5000");
});
答案基本上是尝试总结问题中发表的不同评论。
这个问题可能有很多不同的原因。
要记住的最重要的事情是 EB 提供了一个 nginx 代理来为应用程序提供服务。
By default this proxy 希望您的应用程序侦听端口 5000
。
根据您提供的日志,应用程序似乎正常启动并成功连接到数据库。
正如您所指出的,它报告应用程序正在 侦听 http://localhost:5000
:这可能不是问题,但也许您的应用程序仅在某些网络 interface/address.
只是为了确定,事实上,最后似乎是解决方案,配置您的应用程序 Kestrel 服务器以侦听掩码 http://*:5000
,在您的 [=] 中使用 .UseUrls("http://*:5000")
14=] class,例如。 This article 提供了几个不同的选项来配置应用程序应该在哪里收听。
我正在尝试将具有多个项目的 .Net 6 应用程序部署到 Linux 来自 mac 开发 machine 的 Elastic Beanstalk 服务器。 api 部署后,我无法查询它。我已经通过 2 种方式完成了 - Just an EC2 instance by following this tutorial, just using command line,以及通过 Elastic beantalk 控制台。所以我有 2 个 EC2 实例。他们都说自己是运行ning.
该项目有一个 Asp.Net 应用程序 (Vepo.Web) 和 5 个用于应用层的辅助项目。 “Vepo”项目只是我制作的一个占位符,因为互联网告诉我当你命名你的 dll 与你的解决方案不同时存在错误;解决方案是“Vepo.sln”。
发布创建的文件如下所示:
我通过 cd 获得了要部署到我的 asp.net 核心网络应用程序 (Vepo.Web) 的源代码,然后 运行 dotnet publish -r linux-x64 --self-contained false --output build
,然后转到“Vepo. Web/build”在取景器中。然后select所有文件>右键>压缩(不要压缩父文件夹!)。这会创建“archive.zip”。然后在 Elastic Beanstalk 控制台中上传“archive.zip”。现在它看起来像这样:
但是我好像查询不到api。在 Postman 中,我正在尝试:
ec2-54-xxx-xxx-95.ap-东南-2.compute.amazonaws.com:5001/用户
但我得到:
Error: connect ECONNREFUSED 54.xxx.xxx.95:5000
导航到它给我:
我创建了这些入站规则以允许任何人进入,因为我拼命想进入:
有人可以帮助我在没有获得 404/401 的情况下访问我的网络 API 中的端点吗?如果我遗漏了什么,我会提供任何需要的信息。
更新:我猜当我 ssh 进入应用程序并 运行 这个命令时,应用程序正在 运行ning(不知道如何从邮递员或我的应用程序访问它,在浏览器中访问它不起作用 https://ec2-54-xxx-xxx-53.ap-southeast-2.compute.amazonaws.com:5001/fashionitems/search?searchTerm=B¤tPage=1&pageSize=10):
ubuntu@ip-172-31-44-141:~/app$ ./Vepo.Web —urls http://+:5000 —environment Development
warn: Microsoft.EntityFrameworkCore.Model.Validation[10400]
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
warn: 02/27/2022 03:25:03.441 CoreEventId.SensitiveDataLoggingEnabledWarning[10400] (Microsoft.EntityFrameworkCore.Infrastructure)
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'VeganItem.Tags' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: 02/27/2022 03:25:03.455 CoreEventId.CollectionWithoutComparer[10620] (Microsoft.EntityFrameworkCore.Model.Validation)
The property 'VeganItem.Tags' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
info: 02/27/2022 03:25:03.716 CoreEventId.ContextInitialized[10403] (Microsoft.EntityFrameworkCore.Infrastructure)
Entity Framework Core 6.0.0 initialized 'VepoContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL:6.0.0+025fc55189ae41e3f2b98bcbe4eb44c505653700' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled using NetTopologySuite
dbug: 02/27/2022 03:25:05.976 CoreEventId.QueryCompilationStarting[10111] (Microsoft.EntityFrameworkCore.Query)
Compiling query expression:
'DbSet<VeganItem>()'
dbug: 02/27/2022 03:25:06.200 CoreEventId.QueryExecutionPlanned[10107] (Microsoft.EntityFrameworkCore.Query)
Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<VeganItem>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
EmptyProjectionMember -> Dictionary<IProperty, int> { [Property: VeganItem.Id (int) Required PK AfterSave:Throw ValueGenerated.OnAdd, 0], [Property: VeganItem.CompanyName (string) Required Index MaxLength(256), 1], [Property: VeganItem.CreatedById (string) FK Index MaxLength(256), 2], [Property: VeganItem.CreatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 3], [Property: VeganItem.Description (string) MaxLength(256), 4], [Property: VeganItem.Discriminator (string) Required Index AfterSave:Throw MaxLength(256), 5], [Property: VeganItem.Images (List<string>) MaxLength(10), 6], [Property: VeganItem.IsNotVeganCount (int) Required, 7], [Property: VeganItem.IsVeganCount (int) Required, 8], [Property: VeganItem.Name (string) Required Index MaxLength(256), 9], [Property: VeganItem.Rating (int) Required, 10], [Property: VeganItem.RatingsCount (int) Required, 11], [Property: VeganItem.Tags (List<Option>), 12], [Property: VeganItem.UpdatedById (string) FK Index MaxLength(256), 13], [Property: VeganItem.UpdatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 14], [Property: EventItem.LocationName (string) Required Index MaxLength(256), 15], [Property: FashionItem.Age (Option) Required, 16], [Property: FashionItem.Gender (Option) Required, 17], [Property: RecipeItem.CookTime (TimeSpan) Required, 18], [Property: RecipeItem.Difficulty (Option) Required, 19], [Property: RecipeItem.Ingredients (List<string>) Required MaxLength(100), 20], [Property: RecipeItem.Method (List<string>) Required MaxLength(100), 21], [Property: RecipeItem.PrepTime (TimeSpan) Required, 22], [Property: RecipeItem.ServesCount (int) Required, 23], [Property: RecipeItem.Tips (List<string>) MaxLength(2), 24] }
SELECT v.Id, v.CompanyName, v.CreatedById, v.CreatedDate, v.Description, v.Discriminator, v.Images, v.IsNotVeganCount, v.IsVeganCount, v.Name, v.Rating, v.RatingsCount, v.Tags, v.UpdatedById, v.UpdatedDate, v.LocationName, v.Age, v.Gender, v.CookTime, v.Difficulty, v.Ingredients, v.Method, v.PrepTime, v.ServesCount, v.Tips
FROM VeganItems AS v),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, VeganItem>,
Vepo.DataContext.VepoContext,
False,
True,
True
)'
dbug: 02/27/2022 03:25:06.262 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:06.267 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (34ms).
dbug: 02/27/2022 03:25:06.270 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.464 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.469 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
info: 02/27/2022 03:25:06.546 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (77ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
dbug: 02/27/2022 03:25:06.629 CoreEventId.StartedTracking[10806] (Microsoft.EntityFrameworkCore.ChangeTracking)
Context 'VepoContext' started tracking 'MenuItem' entity with key '{Id: 1}'.
dbug: 02/27/2022 03:25:06.687 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:06.689 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.693 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:06.694 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.695 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
info: 02/27/2022 03:25:06.697 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
dbug: 02/27/2022 03:25:06.698 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:06.698 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.698 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.201 CoreEventId.QueryCompilationStarting[10111] (Microsoft.EntityFrameworkCore.Query)
Compiling query expression:
'DbSet<VeganItemEstablishment>()'
dbug: 02/27/2022 03:25:07.232 CoreEventId.QueryExecutionPlanned[10107] (Microsoft.EntityFrameworkCore.Query)
Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<VeganItemEstablishment>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
EmptyProjectionMember -> Dictionary<IProperty, int> { [Property: VeganItemEstablishment.Id (int) Required PK AfterSave:Throw ValueGenerated.OnAdd, 0], [Property: VeganItemEstablishment.CreatedById (string) FK Index MaxLength(256), 1], [Property: VeganItemEstablishment.CreatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 2], [Property: VeganItemEstablishment.Discriminator (string) Required AfterSave:Throw MaxLength(256), 3], [Property: VeganItemEstablishment.EstablishmentId (int?) FK Index, 4], [Property: VeganItemEstablishment.InEstablishmentCount (int) Required, 5], [Property: VeganItemEstablishment.NotInEstablishmentCount (int) Required, 6], [Property: VeganItemEstablishment.Price (double) Required, 7], [Property: VeganItemEstablishment.UpdatedById (string) FK Index MaxLength(256), 8], [Property: VeganItemEstablishment.UpdatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 9], [Property: VeganItemEstablishment.VeganItemId (int) Required FK Index, 10], [Property: EventItemEstablishment.Dates (List<NpgsqlRange<DateTime>>) Required MaxLength(10), 11] }
SELECT v.Id, v.CreatedById, v.CreatedDate, v.Discriminator, v.EstablishmentId, v.InEstablishmentCount, v.NotInEstablishmentCount, v.Price, v.UpdatedById, v.UpdatedDate, v.VeganItemId, v.Dates
FROM VeganItemEstablishments AS v),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, VeganItemEstablishment>,
Vepo.DataContext.VepoContext,
False,
True,
True
)'
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:07.233 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
info: 02/27/2022 03:25:07.238 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
dbug: 02/27/2022 03:25:07.243 CoreEventId.StartedTracking[10806] (Microsoft.EntityFrameworkCore.ChangeTracking)
Context 'VepoContext' started tracking 'MenuItemEstablishment' entity with key '{Id: 1}'.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:07.291 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
info: 02/27/2022 03:25:07.293 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
dbug: 02/27/2022 03:25:07.293 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:07.294 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.294 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.407 CoreEventId.ContextDisposed[10407] (Microsoft.EntityFrameworkCore.Infrastructure)
'VepoContext' disposed.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/ubuntu/app
P.S。我更喜欢控制台,我是一个 gui 人,宁愿用 AWS 控制台解决这个问题。
这个浏览器消息好点了吗?听起来有点像它存在,但我需要提供 auth/key:
我在 elastic beanstalk 上重新部署并获得了这些日志:
Mar 1 05:55:49 ip-172-31-2-81 web: Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
Mar 1 05:55:49 ip-172-31-2-81 web: SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
Mar 1 05:55:49 ip-172-31-2-81 web: FROM "VeganItemEstablishments" AS v
Mar 1 05:55:49 ip-172-31-2-81 web: info: 3/1/2022 05:55:49.622 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Mar 1 05:55:49 ip-172-31-2-81 web: Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
Mar 1 05:55:49 ip-172-31-2-81 web: SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
Mar 1 05:55:49 ip-172-31-2-81 web: FROM "VeganItemEstablishments" AS v
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
Mar 1 05:55:49 ip-172-31-2-81 web: A data reader was disposed.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Mar 1 05:55:49 ip-172-31-2-81 web: Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Mar 1 05:55:49 ip-172-31-2-81 web: Closed connection to database 'vepo_admin' on server ''.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.714 CoreEventId.ContextDisposed[10407] (Microsoft.EntityFrameworkCore.Infrastructure)
Mar 1 05:55:49 ip-172-31-2-81 web: 'VepoContext' disposed.
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[14]
Mar 1 05:55:49 ip-172-31-2-81 web: Now listening on: http://localhost:5000
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Application started. Press Ctrl+C to shut down.
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Hosting environment: Production
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Content root path: /var/app/current
我猜似乎错误的关键是“正在监听:http://localhost:5000”(那不应该是我的 ec2 实例 public ipv4 地址吗?)和“托管环境:生产“因为我只能确认开发环境正常工作,所以我现在将尝试 运行 在生产版本中本地化。
按照接受的答案添加后,它起作用了。:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://*:5000");
});
答案基本上是尝试总结问题中发表的不同评论。
这个问题可能有很多不同的原因。
要记住的最重要的事情是 EB 提供了一个 nginx 代理来为应用程序提供服务。
By default this proxy 希望您的应用程序侦听端口 5000
。
根据您提供的日志,应用程序似乎正常启动并成功连接到数据库。
正如您所指出的,它报告应用程序正在 侦听 http://localhost:5000
:这可能不是问题,但也许您的应用程序仅在某些网络 interface/address.
只是为了确定,事实上,最后似乎是解决方案,配置您的应用程序 Kestrel 服务器以侦听掩码 http://*:5000
,在您的 [=] 中使用 .UseUrls("http://*:5000")
14=] class,例如。 This article 提供了几个不同的选项来配置应用程序应该在哪里收听。