huc
April 21, 2023, 7:52am
1
Hi,
i have a problem with my .net with mailkit and postgres app on https://wmservice.fly.dev/
When i try to register, verify email or similiar i get 500 server error. On second try or refresh page it work like a charm.
App on my localhost also work properly.
Anyone can help with that?
huc
April 21, 2023, 7:59am
2
here are first few rows from logs:
2023-04-21T07:32:00.016 app[6e82e22a29e687] waw [info] Request starting HTTP/1.1 POST Magazyn application/json 131
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] info: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[5]
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] CORS policy execution failed.
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] info: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[6]
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] Request origin https://wmservice.fly.dev does not have permission to access the resource.
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] Executing endpoint ‘API.Controllers.AccountController.Register (API)’
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
2023-04-21T07:32:00.019 app[6e82e22a29e687] waw [info] Route matched with {action = “Register”, controller = “Account”}. Executing controller action with signature System.Threading.Tasks.Task1[Microsoft.AspNetCore.Mvc.ActionResult
1[API.DTOs.UserDto]] Register(API.DTOs.RegisterDto) on controller API.Controllers.AccountController (API).
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] Failed executing DbCommand (1ms) [Parameters=[@__ToUpper_0=‘?’], CommandType=‘Text’, CommandTimeout=‘30’]
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] SELECT EXISTS (
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] SELECT 1
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] FROM “AspNetUsers” AS a
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] WHERE a.“NormalizedEmail” = @__ToUpper_0 )
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] fail: Microsoft.EntityFrameworkCore.Query[10100]
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] An exception occurred while iterating over the results of a query for context type ‘Data.DataContext’.
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] —> Npgsql.NpgsqlException (0x80004005): Exception while reading from stream
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] —> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] at Npgsql.Internal.NpgsqlReadBuffer.g__EnsureLong|42_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
lubien
April 21, 2023, 11:27am
3
Hi @huc
Our proxy does not return error 500 so I’m thinking this might be an issue with your application code.
I’m not used to .net but looking at your logs 2 things catch my attention:
huc:
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] Failed executing DbCommand (1ms) [Parameters=[@__ToUpper_0=‘?’], CommandType=‘Text’, CommandTimeout=‘30’]
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] SELECT EXISTS (
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] SELECT 1
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] FROM “AspNetUsers” AS a
2023-04-21T07:32:00.020 app[6e82e22a29e687] waw [info] WHERE a.“NormalizedEmail” = @__ToUpper_0 )
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] fail: Microsoft.EntityFrameworkCore.Query[10100]
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] An exception occurred while iterating over the results of a query for context type ‘Data.DataContext’.
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] —> Npgsql.NpgsqlException (0x80004005): Exception while reading from stream
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] —> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
2023-04-21T07:32:00.030 app[6e82e22a29e687] waw [info] at Npgsql.Internal.NpgsqlReadBuffer.g__EnsureLong|42_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
The “has been raised that is likely due to a transient failure” bit tells me this could be the reason your second try worked. Unfortunately, I don’t know how to help you more with that particular issue.
huc
April 21, 2023, 12:16pm
4
Thank you for your reply. My cors policy was still set up on localhost, and EF Core needs additional configuration to db connection:
opt.UseNpgsql(connString, builder => {
builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
});
Thanks again.
Cheers
1 Like
system
Closed
April 28, 2023, 12:16pm
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.