Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Agent In Docker

Agent in docker

By thiesens, 30 September, 2024
Forums
Gurux.DLMS.AMI

Hi Gurux.

Will you be adding a version of the agent, to run in docker?

/Henrik

thiesens

1 year 3 months ago

was thinking: Add params to…

was thinking:

Add params to class:

static string serverName = Environment.GetEnvironmentVariable("GURUX_SERVER") ?? "https://localhost:8001";
static string hostName = Environment.GetEnvironmentVariable("GURUX_HOST") ?? System.Net.Dns.GetHostName();
static string token = Environment.GetEnvironmentVariable("GURUX_TOKEN");

Change the RegisterAgent:

public static async Task RegisterAgent(
IServiceCollection services,
AutoResetEvent newVersion,
IGXAgentWorker worker,
AgentOptions options)
{
string name = hostName ?? System.Net.Dns.GetHostName();
if (string.IsNullOrEmpty(token))
{
Console.WriteLine("Running on host. Collecting params");
// string name = System.Net.Dns.GetHostName();
Console.WriteLine("Welcome to use Gurux.DLMS.AMI.");
Console.WriteLine(string.Format("Gurux.DLMS.AMI address: [{0}]", options.Address));
string? tmp = Console.ReadLine();
if (!string.IsNullOrEmpty(tmp))
{
options.Address = tmp;
}
Console.WriteLine(string.Format("Enter agent name: [{0}]", name));
tmp = Console.ReadLine();
if (!string.IsNullOrEmpty(tmp))
{
name = tmp;
}
Console.WriteLine("Enter Personal Access Token:");
options.Token = Console.ReadLine();
if (options.Token == null || options.Token.Length != 64)
{
throw new ArgumentException("Invalid token.");
}
}
else
{
Console.WriteLine("Running in a container.");
options.Address = serverName;
name = hostName;
options.Token = token;
}

worker.Init(services, options, newVersion);
options.Id = await worker.AddAgentAsync(name);
if (options.Id == Guid.Empty)
{
throw new ArgumentException("Invalid agent Id.");
}
File.WriteAllText(settingsFile, JsonSerializer.Serialize(options));
Console.WriteLine("Connection succeeded.");
}

Add a dockerfile, and run it with the 3 env variables.

Profile picture for user Kurumi

Kurumi

1 year 3 months ago

Hi Henrik, Yes, this is…

Hi Henrik,

Yes, this is possible. The new Gurux.DLMS.AMI tests start next week. I'll check if it is possible to add this before the next version is released, but it's coming latest with the new version.

BR,
Mikko

thiesens

1 year 3 months ago

Perfect Mikke. Looking…

Perfect Mikke.

Looking forward to this.

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 01/14/2026 - 14:29
    Gurux.DLMS.Python 1.0.196
  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5
  • Mon, 12/15/2025 - 08:11
    Gurux.DLMS.Net 4.0.87
  • Fri, 12/12/2025 - 08:38
    Gurux.DLMS.Python 1.0.195
  • Thu, 12/11/2025 - 13:22
    Gurux.DLMS.Python 1.0.194

New forum topics

  • 6-digit field values from meter not fully received (only 5 digits shown)
  • Gurux DLMS Android App
  • AMR support for bidirectional meters.
  • addition of new object in object list, meter not working
  • old meter take to much time(l&t)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin