C
C#•4mo ago
Ares

help deploying asp.net app docker image to render.com

So I am trying to deploy my docker image to render.com, but once I deploy my app i see in the logs the following error:
==> Detected service running on port 8080
==> Docs on specifying a port: https://render.com/docs/web-services#port-detection
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://realtime-poll-latest.onrender.com/ - - -
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN1LRGSD9E4D", Request id "0HN1LRGSD9E4D:00000001": An unhandled exception was thrown by the application.
System.ArgumentException: The 'ClientId' option must be provided. (Parameter 'ClientId')
at Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions.Validate()
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions.Validate(String scheme)
at Microsoft.AspNetCore.Authentication.AuthenticationBuilder.<>c__DisplayClass4_0`2.<AddSchemeHelper>b__1(TOptions o)
at Microsoft.Extensions.Options.ValidateOptions`1.Validate(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
==> Detected service running on port 8080
==> Docs on specifying a port: https://render.com/docs/web-services#port-detection
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://realtime-poll-latest.onrender.com/ - - -
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN1LRGSD9E4D", Request id "0HN1LRGSD9E4D:00000001": An unhandled exception was thrown by the application.
System.ArgumentException: The 'ClientId' option must be provided. (Parameter 'ClientId')
at Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions.Validate()
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions.Validate(String scheme)
at Microsoft.AspNetCore.Authentication.AuthenticationBuilder.<>c__DisplayClass4_0`2.<AddSchemeHelper>b__1(TOptions o)
at Microsoft.Extensions.Options.ValidateOptions`1.Validate(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
i already added the clientid and clientsecret environment variables to render.com, but for some reason i still get the above error. it works fine locally but once i deploy i get error 500 whenever i try to load the app. how can i fix this?
No description
10 Replies
Ares
Ares•4mo ago
appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"GoogleKeys": {
"ClientId": "<clientid>",
"ClientSecret": "<clientsecret>"
},
"ConnectionStrings": {
"DefaultConnection": "Host=db;Port=5432;Database=realtime_poll;User Id=<userid>;Password=<password>SSL Mode=Disable;" **for IIS express, host should be localhost not db**
}
}
appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"GoogleKeys": {
"ClientId": "<clientid>",
"ClientSecret": "<clientsecret>"
},
"ConnectionStrings": {
"DefaultConnection": "Host=db;Port=5432;Database=realtime_poll;User Id=<userid>;Password=<password>SSL Mode=Disable;" **for IIS express, host should be localhost not db**
}
}
https://github.com/JBrown58/realtime-poll
tera
tera•4mo ago
keys here need to be
GoogleKeys__ClientId
GoogleKeys__ClientSecret
GoogleKeys__ClientId
GoogleKeys__ClientSecret
tera
tera•4mo ago
also prefer using dotnet user-secrets for secrets for development, and keep appsettings.json committed to your repository that way
Ares
Ares•4mo ago
ok thanks
Ares
Ares•4mo ago
Your service is live 🎉
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://realtime-poll-latest.onrender.com/ - - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'realTimePolls.Controllers.HomeController.Index (realTimePolls)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
Route matched with {action = "Index", controller = "Home"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Index() on controller realTimePolls.Controllers.HomeController (realTimePolls).
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
**An error occurred using the connection to database 'realtime_poll' on server 'tcp://db:5432'.**
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'realTimePolls.Models.RealTimePollsContext'.
** System.Net.Sockets.SocketException (00000005, 0xFFFDFFFF): Name does not resolve**
at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, Nullable`1 startingTimestamp)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress, AddressFamily family)
at Npgsql.Internal.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|213_1(NpgsqlConnector conn, SslMode
Your service is live 🎉
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://realtime-poll-latest.onrender.com/ - - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'realTimePolls.Controllers.HomeController.Index (realTimePolls)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
Route matched with {action = "Index", controller = "Home"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Index() on controller realTimePolls.Controllers.HomeController (realTimePolls).
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
**An error occurred using the connection to database 'realtime_poll' on server 'tcp://db:5432'.**
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'realTimePolls.Models.RealTimePollsContext'.
** System.Net.Sockets.SocketException (00000005, 0xFFFDFFFF): Name does not resolve**
at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, Nullable`1 startingTimestamp)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress, AddressFamily family)
at Npgsql.Internal.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|213_1(NpgsqlConnector conn, SslMode
for some reason after i deploy, i can see my app now but when i am on the homepage it redirects me to the error page saying: Request ID: Name does not resolve.
No description
Ares
Ares•4mo ago
i think the reason for the name error is the fact that it says An error occurred using the connection to database 'realtime_poll' on server 'tcp://db:5432'. though not sure why its failing to connect in prod but works fine locally. Host=db;Port=5432;Database=realtime_poll;User Id=<id>;Password=<password>; this is the connection string i am using in dev and prod
Ares
Ares•4mo ago
also when i try to login now, it says the redirect uri is wrong. but i cant add http uri to google cloud console, it wont let me. so im not sure why its givin gme https instead of http. I cant login anymore, even though my docker runs just fine
No description
tera
tera•4mo ago
i'm not familiar with render, dunno. but that sounds like you dont have the db container running in same docker network so it can't resolve the address or at all
Ares
Ares•4mo ago
oh ok thanks