Exception while running AMI server on Centos

30 posts / 0 new
Last post
rahul.singh@rad...
Exception while running AMI server on Centos

Hi Mikko ,

When i am trying to run GuruxAMI on Centos server
we are getting following exception

System.Net.Http.HttpRequestException: Connection refused
---> System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Gurux.DLMS.AMI.Startup.AddSchedule() in C:\vsts-agent-win7-x64-2.124.0\_work\39\s\Gurux.DLMS.AMI\Startup.cs:line 134
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Aborted

Kurumi
Kurumi's picture

Hi,

1. Try to change localhost to your IP address.
Change this from appsettings.json
"Client": {
"Address": "http://localhost:64881"
},
to
"Client": {
"Address": "http://YOUR IP ADDRESS:64881"
},

It's not yet clear why localhost is not working on Linux.

2. Run your app with sudo.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

Hi Mikko ,

Did the same , But getting same exception.

My appsetting.jsom

"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"Reader": {
"Id": "603C1F03-6EDE-4F4F-B108-3451383F0B0F",
"Name": "Default",
"Threads": 10,
"TaskWaitTime": 60
},
"Scheduler": {
"Disabled": "False"
},
"Listener": {
"Port": 1000,
"Interface": 0,
"UseLogicalNameReferencing": "True",
"ClientAddress": 16,
"ServerAddress": 1,
"Authentication": 0,
"Password": null,
"Security": 0,
"InvocationCounter": "0.0.43.1.1.255",
"DefaultDeviceTemplate": 0
},
"Notify": {
"Port": 4059,
"ExpirationTime": 60,
"Parser": "Gurux.DLMS.AMI.NotifyParser.dll;Gurux.DLMS.AMI.NotifyParser.GXNotifyParser"
},
"Server": {
"Address": "http://*:9002"
},
"Client": {
"Address": "http://192.168.100.88:9002"
},
"Database": {
"Type": "SQLite",
"Settings": "Data Source=:memory:"
}
}

Exception:

Listening port:1000
Notifing port:4059
RestAddress: http://192.168.100.88:9002
Database type: SQLite
Connecting: Data Source=:memory:
Creating tables.
Unhandled exception. Service started: http://192.168.100.88:9002
System.Net.Http.HttpRequestException: Connection refused
---> System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Gurux.DLMS.AMI.Startup.AddSchedule() in C:\vsts-agent-win7-x64-2.124.0\_work\39\s\Gurux.DLMS.AMI\Startup.cs:line 134
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Aborted

Kurumi
Kurumi's picture

Hi,

Can you run this and post result here.

dotnet --version

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

HI Miiko ,

[root@ip-192-168-100-88]# dotnet --list-runtimes

Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

[root@ip-192-168-100-88]# dotnet --list-sdks

2.1.4 [/usr/share/dotnet/sdk]
3.1.101 [/usr/share/dotnet/sdk]

[root@ip-192-168-100-88]# dotnet --version
3.1.101

polyrem

My AMI ( On Centos 7, and on Windows server 2016, with .NET 3.1.101 ) starts with same log mesages,
Connection refused
+++++++++++++++++++++++++
System.Net.Http.HttpRequestException: Connection refused
---> System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Gurux.DLMS.AMI.Reader.ReaderService.DoWork() in C:\vsts-agent-win7-x64-2.124.0\_work\39\s\Gurux.DLMS.AMI\Reader\ReaderService.cs:line 106

but ends with:
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.

rahul's AMI aborted, but mine works, and waits ( on port 1000 ) for data from meter.

But it is impossible to set GXDLMSDirector. After check DataConcentrator there is an error message ( without message ):

Test connection is succeeded, but it is no possible to import template.

Image: 
Kurumi
Kurumi's picture

Hi,

Have you installed .AspNetCore.ASP?
Can you run this:
dotnet --list-runtimes
and this
dotnet --list-sdks

Then check differences:
dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.15 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.15 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.15 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

polyrem

dotnet --list-runtimes
Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

dotnet --list-sdks
3.1.101 [C:\Program Files\dotnet\sdk]

polyrem

and on Centos:
dotnet --list-runtimes
Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

dotnet --list-sdks
3.1.101 [/usr/share/dotnet/sdk]

Kurumi
Kurumi's picture

Hi,

It works without problems with clean install.
Have you installed Apache?

Run this:
sudo yum update -y
sudo yum -y install httpd mod_ssl

If it still fails, get the source code:
https://github.com/Gurux/Gurux.DLMS.AMI/archive/master.zip
then try to build this with
dotnet build Gurux.DLMS.AMI.sln

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

Hi Mikko ,

Httpd is installed
[root@ip-192-168-100-88]# yum install httpd -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Repository packages-microsoft-com-prod is listed more than once in the configuration
33 packages excluded due to repository priority protections
Package httpd-2.4.41-1.amzn2.0.1.x86_64 already installed and latest version
Nothing to do

Build with provided source code
But still we are getting following exception

Listening port:1000
Notifing port:4059
RestAddress: http://localhost:64881
Database type: SQLite
Connecting: Data Source=:memory:
Creating tables.
Unhandled exception. Service started: http://localhost:64881
System.Net.Http.HttpRequestException: Connection refused
---> System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Gurux.DLMS.AMI.Startup.AddSchedule() in /opt/RadiusHES/Gurux.DLMS.AMI-master/Gurux.DLMS.AMI/Startup.cs:line 134
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Aborted

rahul.singh@rad...

* localhost changed with IP

Unhandled exception. Service started: http://192.168.100.88:648
System.Net.Http.HttpRequestException: Connection refused

OS Details:

uname -a
Linux ip-192-168-100-88.ap-south-1.compute.internal 4.14.146-119.123.amzn2.x86_64 #1 SMP Mon Sep 23 16:58:43 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

rahul.singh@rad...

Hi Mikko

It will also support IPV6 as server .

Kurumi
Kurumi's picture

Hi,

Linux gurux-test 3.10.0-1062.9.1.el7.x86_64 #1 SMP Fri Dec 6 15:49:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

We'll modify the Gurux.DLMS.AMI so you can try to connect using curl and get some info.
I'll send more info in the following hours.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

Kurumi
Kurumi's picture

Hi,

I believe that this is now solved. Get the latest version.
I don't know why it was working on a few Centos and failed for some.

If you try to access Gurux.DLMS.AMI from the other PC you must modify firewall settings.
You can try get info from other pc with default browsers.

http://IP_ADDRESS/api/info

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

Kurumi
Kurumi's picture

Hi,

Now I know the reason for this. It was a timing issue. For some reason, REST was not SOMETIMES up and running. We added a small delay before starting reader service and now it's working without problems.

BR,

Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

Kurumi
Kurumi's picture

Hi,

We have found other issues from the JSON serializer. We have made a few changes and release a new version tomorrow.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

Hi Mikko ,

Sorry for delayed response .
Was unable to Reply & Test yesterday.
Will test and update you .

rahul.singh@rad...

Hi Mikko ,

Sorry for delayed response .
Was unable to Reply & Test yesterday.
Will test and update you .

Kurumi
Kurumi's picture

Hi Rahul,

We found another problem. .Net Core JSON serialization is not work correctly for all the data.
You saw this problem with GXDLMSDirector in your previous posts.

We are fixing this and try to release a new version latest tomorrow.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

Ok Thank you

rahul.singh@rad...

Hi Mikko

There is one more observation

1. Socket state is listening even after closing application.

and Thanks this version is working on my Centos without any exception.

Kurumi
Kurumi's picture

Hi,
There are new versions from Gurux.DLMS.AMI and GXDLMSDirector.
We have change data structure so .Net Core 3.1 for Linux can handle it.

About socket listening. Are you talking from the socket that meter opens?

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

No . Socket where GuruX is listening (1001)

Kurumi
Kurumi's picture

Hi,

How you close the app and how you can see that socket is up? We'll check this.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

We are terminating app with (ctrl+C).

Checking port status with
netstat -apn | grep "1001"

Kurumi
Kurumi's picture

Hi,

You are right and we know why this is happening. We'll fix this for the next release.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

Thanks

Kurumi
Kurumi's picture

Hi Rahul,

This is fixed.

BR,

Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

rahul.singh@rad...

Thanks Mikko . for your continuous support :)