Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
Hello,
I pulled the AMI docker image and run docker run guruxorg/guruxdlmsamiserver. It showed:
Database type: MSSql
Connecting: Server=SQL_SERVER;Database=msdb;User ID=USER_ID;Password='USER_PASSWORD'
Then it failed with this error message below:
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
Thanks for your response,
The reason why I ran 'docker run guruxorg/guruxdlmsamiserver' is because the instruction on https://hub.docker.com/r/guruxorg/guruxdlmsamiserver says you don't need to set up any database to test the system. so you can just run it and see it working before you may set external database later.
However, I also set up my xampp SQL database which runs locally on my PC at http://localhost/phpmyadmin I created a DB amr-project, user: root and without password. I generated the HTTPS certificate and then ran docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=localhost;Database=amr-project;UID=root;Password=" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
and I got this error:
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
---> System.Net.Sockets.SocketException (111): Connection refused
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.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
I installed MySQL and still receiving some errors.
Then I installed sqlite3 and run it, this is what I got.
docker run --rm -it -e "Database:Type=SQLite" -e "Database:Settings=Filename=:memory:" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
Database type: SQLite
Connecting: Filename=:memory:
Unhandled exception. System.ArgumentException: Data Source cannot be empty. Use :memory: to open an in-memory database
at System.Data.SQLite.SQLiteConnection.Open()
at Gurux.Service.Orm.GXDbConnection..ctor(DbConnection[] connections, String tablePrefix)
at Gurux.DLMS.AMI.Server.ServerSettings.ConnectToDb(WebApplicationBuilder builder) in /src/Gurux.DLMS.AMI/Server/ServerSettings.cs:line 618
at Program.<Main>$(String[] args) in /src/Gurux.DLMS.AMI/Server/Program.cs:line 53
at Program.<Main>(String[] args)
Database type: MySQL
Connecting: Server=DESKTOP-RM84GI7;Database=amr-project;UID=root;Password=12345
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)
at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_0(Object s, ValueStopwatch stopwatch)
I realized I was using my wifi name instead of my PC name. Now that I've used the correct name, I'm getting a different error message.
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Host 'host.docker.internal' is not allowed to connect to this MySQL server
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
I tried it again, and it shows
Host 'tukur-desktop.mshome.net' is not allowed to connect to this MySQL server
Problem Resolved! And I was able to launch the App successfully.
For the benefit of new users:
The problem I got was a result of these:
1. I used my wifi-name instead of my PC name at Database: Settings=Server
2. I was using the default root user for MySQL which doesn't allow remote connection (Docker is also considered a remote connection). So I created a new user in MySQL who can access any IP address and used that for the database connection
Hi, You need to change SQL…
Hi,
You need to change SQL_SERVER to the name or TCP/IP address where your SQL server is.
You need to change also USER_ID and USER_PASSWORD to the correct values.
BR,
Mikko
Thanks for your response,…
Thanks for your response,
The reason why I ran 'docker run guruxorg/guruxdlmsamiserver' is because the instruction on https://hub.docker.com/r/guruxorg/guruxdlmsamiserver says you don't need to set up any database to test the system. so you can just run it and see it working before you may set external database later.
However, I also set up my xampp SQL database which runs locally on my PC at http://localhost/phpmyadmin I created a DB amr-project, user: root and without password. I generated the HTTPS certificate and then ran docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=localhost;Database=amr-project;UID=root;Password=" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
and I got this error:
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
---> System.Net.Sockets.SocketException (111): Connection refused
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.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
Thanks in anticipation of your helpful response.
Hi, I believe that you don't…
Hi,
I believe that you don't have MySQL installed on your PC.
You don't need to install the DB if you use SQLite. Chech this:
Run a container using SQLite in-memory database:
Get also the latest version. There are some user creation issues fixed.
BR,
Mikko
Good day, I installed MySQL…
Good day,
I installed MySQL and still receiving some errors.
Then I installed sqlite3 and run it, this is what I got.
docker run --rm -it -e "Database:Type=SQLite" -e "Database:Settings=Filename=:memory:" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
Database type: SQLite
Connecting: Filename=:memory:
Unhandled exception. System.ArgumentException: Data Source cannot be empty. Use :memory: to open an in-memory database
at System.Data.SQLite.SQLiteConnection.Open()
at Gurux.Service.Orm.GXDbConnection..ctor(DbConnection[] connections, String tablePrefix)
at Gurux.DLMS.AMI.Server.ServerSettings.ConnectToDb(WebApplicationBuilder builder) in /src/Gurux.DLMS.AMI/Server/ServerSettings.cs:line 618
at Program.<Main>$(String[] args) in /src/Gurux.DLMS.AMI/Server/Program.cs:line 53
at Program.<Main>(String[] args)
What am I doing wrong?
Hi, If you are using MySql…
Hi,
If you are using MySql your comman line argument are:
Where HOST is name of your PC where you did install MySQL.
DATABASE_SERVER is name of your database.
in Linux:
docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=HOST;Database=DATABASE_SERVER;UID=USER_ID;Password=DATABASE_PASSWORD" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="YOUR_CREDENTIAL_PASSWORD" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v ${HOME}/.aspnet/https:/https/ guruxorg/guruxdlmsamiserver:latest
In Windows:
ocker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=HOST;Database=DATABASE_SERVER;UID=USER_ID;Password=DATABASE_PASSWORD" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="YOUR_CREDENTIAL_PASSWORD" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v %USERPROFILE%.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
Let me know if you have problems.
BR,
Mikko
Thanks for your response. I…
Thanks for your response.
I ran it as instructed but I still can't resolve it.
docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=DESKTOP-RM84GI7;Database=amr-project;UID=root;Password=12345" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
Database type: MySQL
Connecting: Server=DESKTOP-RM84GI7;Database=amr-project;UID=root;Password=12345
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)
at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_0(Object s, ValueStopwatch stopwatch)
I realized I was using my…
I realized I was using my wifi name instead of my PC name. Now that I've used the correct name, I'm getting a different error message.
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Host 'host.docker.internal' is not allowed to connect to this MySQL server
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
I tried it again, and it shows
Host 'tukur-desktop.mshome.net' is not allowed to connect to this MySQL server
Problem Resolved! And I was…
Problem Resolved! And I was able to launch the App successfully.
For the benefit of new users:
The problem I got was a result of these:
1. I used my wifi-name instead of my PC name at Database: Settings=Server
2. I was using the default root user for MySQL which doesn't allow remote connection (Docker is also considered a remote connection). So I created a new user in MySQL who can access any IP address and used that for the database connection
and that was it.
Thanks for your time @Kurumi
Hi, Thank you very much for…
Hi,
Thank you very much for this information. Your attention from the root user is excellent. That is added to the documentation.
BR,
Mikko