Docker Compose with nopCommerce and Connection with SQL Server Management

Hace 3 semanas
Hello,
I have installed nopCommerce with Docker Compose, and I can connect to it using the open ports without any problem.

Problem 1:
I would now like to launch my Visual Studio solution to connect to the same database created with Docker Compose.
I have correctly set the "connectionstring" in the appsettings of AppData. I don't get any errors, but when I launch the site, I get the error "This page isn’t working", and I don't even get into the "actions" of the "controllers".
Connection string in appsettings:
data source=127.0.0.1,1433;initial catalog=nopcommerce;user id=sa;password=nopCommerce_db_password;TrustServerCertificate=True;MultipleActiveResultSets=true

Problem 2:
I am having difficulties viewing the database from "Visual Studio Management". I can connect to the "localhost" instance with the "sa" and password, but no database is displayed.
Through a command line: "docker exec -it 1cc84ca0bd8f /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "nopCommerce_db_password"", I connect to the SQL instance without any problem and I can see the database.
version: "3.4"
services:
    nopcommerce_web:
        build: .
        container_name: nopcommerce
        ports:
            - "8010:80"
        depends_on:
            - nopcommerce_database
        volumes:
          - nopcommerce_web:/app
        environment:
          ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT}
          
    nopcommerce_database:
        image: "mcr.microsoft.com/mssql/server:2019-latest"
        container_name: nopcommerce_mssql_server
        expose:
          - "1433"
        environment:
            SA_PASSWORD: ${SA_PASSWORD}
            ACCEPT_EULA: "Y"
            MSSQL_PID: "Express"
        ports:
          - "1433:1433"
        volumes:
          - nopcommerce_db:/var/opt/mssql

volumes:
  nopcommerce_data:        
  nopcommerce_db:  
  nopcommerce_web:
Hace 3 semanas
RE:  error "This page isn’t working"
Could be a browser issue (cookies, etc.).  Try to access your website from a different browser or Incognito mode.

RE: "difficulties viewing the database from "Visual Studio Management"
Can you connect with SSMS?
Hace 3 semanas
Most probably it seems like studio is unable to find or connect to the database. Are you able to connect & login to the database when you try from management studio? Sometimes, it may be just the way we write connection string for it. Try giving it connection string in different format, try change address too and it should work.
Hace 3 semanas
With Docker, the URL: http://localhost:8012/ works perfectly, and I can access the site.
With Visual Studio, the URL http://localhost:5001/ does not work "this page isn’t working".
I retry install complete and now with Visual Studio Management:
→I can connect, database is displayed.
The last problem is visual studio and the page isn't wxorking if the problem come the connection string...
I don't think that problem is the connection string, because if I change the format I have the error : Microsoft.Data.SqlClient.SqlException : 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Hace 2 semanas
Hello,
I confirm that the problem does not stem from the database connection.
I placed a breakpoint in the "GetCurrentStore" function, and I see that it has correctly retrieved the data from the table in the database for the store.
I have this error in log database:

447  La tâche planifiée "Send emails" a échoué avec l'erreur "Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée. (localhost:8012)" (Type de tâche: "Nop.Services.Messages.QueuedMessagesSendTask, Nop.Services". Nom du magasin: "Your store name". Adresse d'exécution de la tâche: "http://localhost:8012/scheduletask/runtask").    NULL  40  System.Net.Http.HttpRequestException: Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée. (localhost:8012)
---> System.Net.Sockets.SocketException (10061): Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendAsync>g__Core|5_0(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendAsync>g__Core|5_0(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Nop.Services.ScheduleTasks.TaskScheduler.TaskThread.RunAsync() in C:\Users\Beaujean\Documents\source\repos\LubrigroupNopCommerce\Lubrigroup.Source\Libraries\Nop.Services\ScheduleTasks\TaskScheduler.cs:line 191      2024-04-09 19:04:46.087987
Hace 2 semanas
Are you able to connect to the db hosted inside docker using SSMS?
Hace 2 semanas
Your "error in the log" is not a DB problem, it's the Email sending scheduled task failing probably because the URL in your Admin > Stores is still referencing localhost:8012, which would not be correct if in VS you are running localhost:5001
The scheduled task "Send emails" failed with the error 
"A connection could not be established because the target computer expressly refused it. (localhost:8012)"
(Task type: "Nop.Services. Messages.QueuedMessagesSendTask, Nop.Services".
Store name: "Your store name".
Task execution address: "http://localhost:8012/scheduletask/runtask").


RE: "I placed a breakpoint in the "GetCurrentStore" function, and I see that it has correctly retrieved the data from the table in the database for the store."
Please clarify that.  What do you see 5001 or 8012?
Hace 2 semanas
New York wrote:
Your "error in the log" is not a DB problem, it's the Email sending scheduled task failing probably because the URL in your Admin > Stores is still referencing localhost:8012, which would not be correct if in VS you are running localhost:5001
The scheduled task "Send emails" failed with the error 
"A connection could not be established because the target computer expressly refused it. (localhost:8012)"
(Task type: "Nop.Services. Messages.QueuedMessagesSendTask, Nop.Services".
Store name: "Your store name".
Task execution address: "http://localhost:8012/scheduletask/runtask").


RE: "I placed a breakpoint in the "GetCurrentStore" function, and I see that it has correctly retrieved the data from the table in the database for the store."
Please clarify that.  What do you see 5001 or 8012?

Thanks for your help, I change my port for localhost and now it's working