Read basic information from Gurux.DLMS component before you start to create DLMS client. Source codes of this example are available on GitHub.

Reading meters using Dynamic IP addresses in GPRS connection

If you want to read your meters using GPRS connection you must have static IP addresses on your meters (SIM card). If you have dynamic IP addresses, your meter must always start the connection to the server. This means that your meter can send example scheduled push messages, but you can't read your meter when you want to. In public GPRS networks, connections are always established from modem to GPRS network, and never from GPRS network to modem. It is not possible for a client application to open a connection.
  • Static IP address: Meter or reading system can start the connection.
  • Dynamic IP address: Meter always starts the connection.
In this document I'll go through the reading meters with dynamic IP addresses superficially and purpose is explain how to get data from the meter when meter uses dynamic IP address. When meters are using dynamic IP addresses or firewall blocks access to the meter, it's possible that meter is scheduled to make connection to the server using TCP/IP connection with given time interval.
Note! All meters do not support this.

In this simple example server waits TCP/IP connections from the meters and when new TCP/IP connection is established it will start to act like DLMS Client. In this example I only show how to establish connection to the meter after meter has made TCP/IP connection. We have used meter that only makes connection to the server. Some meters are first sending some initializing information. Because this is manufacturer depending, I do'y go it through here.


If you want to build source codes you need Nuget package manager for Visual Studio. You can get it here.

Simple example

First we create TCP/IP server what listens given port. We are using GXNet as TCP/IP server.
GXNet server = new GXNet(NetworkType.Tcp, 1234);
server.OnClientConnected += OnClientConnected;
GXNet server = new GXNet(NetworkType.TCP, 1000);
GXListener listener = new GXListener();

//implement listener class
public class GXListener extends Thread implements IGXMediaListener, IGXNetListener {
Main idea is listen incoming connections. When connection is established, we attach connection from server and use connection what meter has made.
/// <summary>New client is connected. </summary>
/// <param name="sender">Server component.</param>
/// <param name="e">Connection parameters,</param>
private static void OnClientConnected(object sender, Common.ConnectionEventArgs e)
    Console.WriteLine("Client {0} is connected.", e.Info);
    GXNet server = (GXNet)sender;
        using (GXNet cl = server.Attach(e.Info))
            GXDLMSReader cl = new Net.GXDLMSReader(media);
            //Create own thread for each meter if you are handling multiple meters simultaneously.
            //new Thread(new ThreadStart(cl.ReadAll));
    catch (Exception ex)
public void onClientConnected(Object sender, ConnectionEventArgs e) {
    System.out.println(String.format("Client '%1$s' is connected.", e.getInfo()));
    GXNet server = (GXNet) sender;
    try {
        try (GXNet cl = server.attach(e.getInfo())) {
    } catch (Exception ex) {
In ReadAll function we initialize connection and read data from the meter. You can access meter as normal client. You can find more information how to read your meter from Gurux web page.

Note! This is only example. If you want to read multiple meters at the same time you need to create own thread for each meter.
Thats it. If you have any questions or ideas how to improve Gurux.DLMS component let us know or ask question in a Forum