Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

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

Breadcrumb

  1. Home
  2. Unable To Connect Electric Smart Meter.(aarq Request Failed)

Unable to connect electric smart meter.(aarq request failed)

By jayaram , 23 August, 2024
Forums
Gurux.Net

GXDLMSSecureClient sclient = new GXDLMSSecureClient();
GXNet gXNet = new GXNet(NetworkType.Tcp, "ip address", 4059);
sclient.UseLogicalNameReferencing = true;

// Is used HDLC or COSEM transport layers for IPv4 networks (IEC 62056-47)
sclient.InterfaceType = InterfaceType.WRAPPER;
sclient.ClientAddress = 32;
sclient.ServerAddress = 1;
sclient.Authentication = Authentication.Low;
sclient.Password = ASCIIEncoding.ASCII.GetBytes("123456");
sclient.Ciphering.SecuritySuite = SecuritySuite.Suite0;
sclient.Ciphering.Security = Security.AuthenticationEncryption;

sclient.Ciphering.SystemTitle = GXCommon.HexToBytes("7177657274797569");

sclient.Ciphering.BlockCipherKey = GXCommon.HexToBytes("62626262626262626262626262626262");
sclient.Ciphering.AuthenticationKey = GXCommon.HexToBytes("62626262626262626262626262626262");
sclient.Ciphering.Signing = Signing.None;

Media = gXNet as IGXMedia;
Media.Open();

GXReplyData reply = new GXReplyData();
byte[] data;
data = sclient.SNRMRequest();
if (data != null)
{
ReadDLMSPacket(data, reply);
sclient.ParseUAResponse(reply.Data);
}
//Generate AARQ request.
//Split requests to multiple packets if needed.
//If password is used all data might not fit to one packet.
foreach (byte[] it in sclient.AARQRequest())
{
Console.WriteLine("Send AARQ request-{0}", GXCommon.ToHex(it, true));
reply.Clear();
reply = ReadDLMSPacket(it, reply);
}

//Parse reply.
sclient.ParseAAREResponse(reply.Data);
Console.WriteLine("Conformance: " + sclient.NegotiatedConformance);
Console.WriteLine(sclient.ConnectionState);

byte[][] obj = sclient.Read("0.0.42.0.0.255", ObjectType.Data, 2);
/// Read Association View from the meter.
reply = new GXReplyData();
ReadDataBlock(obj, reply);

public static GXReplyData ReadDLMSPacket(byte[] data, GXReplyData reply)
{
if (data == null)
{
return reply;
}
object eop = (byte)0x7E;
//In network connection terminator is not used.

int pos = 0;
bool succeeded = false;
ReceiveParameters<byte[]> p = new ReceiveParameters<byte[]>()
{
AllData = true,
Eop = eop,
Count = 5,
WaitTime = 5000,
};
lock (Media.Synchronous)
{
while (!succeeded && pos != 3)
{
Media.Send(data, null);
succeeded = Media.Receive(p);
Console.WriteLine("Response-{0}", GXCommon.ToHex(p.Reply, true));
if (!succeeded)
{
//If Eop is not set read one byte at time.
if (p.Eop == null)
{
p.Count = 1;
}
//Try to read again...
if (++pos != 3)
{
System.Diagnostics.Debug.WriteLine("Data send failed. Try to resend " + pos.ToString() + "/3");
continue;
}
throw new Exception("Failed to receive reply from the device in given time.");
}
}
//Loop until whole COSEM packet is received.
while (!client.GetData(p.Reply, reply))
{
//If Eop is not set read one byte at time.
if (p.Eop == null)
{
p.Count = 1;
}
if (!Media.Receive(p))
{
//Try to read again...
if (pos != 3)
{
System.Diagnostics.Debug.WriteLine("Data send failed. Try to resend " + pos.ToString() + "/3");
continue;
}
throw new Exception("Failed to receive reply from the device in given time.");
}
}
}
if (reply.Error != 0)
{
throw new GXDLMSException(reply.Error);
}

return reply;
}

Profile picture for user Kurumi

Kurumi

1 year 9 months ago

Hi, Please, don't copy the…

Hi,

Please, don't copy the example code. It doesn't say anything about the problem.

Are you getting any reply from the meter?
I believe that one of your settings is different than the meter expects.
Try to connect with GXDLMSDirector to get the correct settings.

BR,
Mikko

jayaram

1 year 9 months ago

I am connection with wrapper…

I am connection with wrapper interface type but its not working and i tried with gxdlmsdirector it is working

Send AARQ request-00 01 00 20 00 01 00 55 60 53 A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 71 77 65 72 74 79 75 69 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 08 80 06 31 32 33 34 35 36 BE 23 04 21 21 1F 30 00 00 00 02 B9 C9 87 9D 5B 75 7F 27 5C 00 73 25 83 4B 71 A9 03 13 C6 2F 58 AC 36 10 5F 48

Response-00 01 00 01 00 20 00 0C 4E 45 58 45 52 52 4F 52 4E 4F 2D 31

Profile picture for user Kurumi

Kurumi

1 year 9 months ago

Hi, Can you add the first…

Hi,

Can you add the first message that GXDLMSDirector sends? I can get the correct settings for you.

I believe that you are reading the Innovation counter with GXDLMSDirector and that is causing the issue.

BR,
Mikko

jayaram

1 year 9 months ago

Hi, Issue is resolved.I set …

Hi,

Issue is resolved.I set object eop = null instead of object eop = (byte)0x7E;

but now meter is responding properly for the first time after that if i try to connect second time its showing serviceerror Initiate error exception.

If i turned off the meter and turned on again then its working.what may be the reason?

Profile picture for user Kurumi

Kurumi

1 year 9 months ago

Hi, At first, ask if there…

Hi,

At first, ask if there is a firmware update available for the meter.
Did you call close after you have read the values from the meter?

BR,
Mikko

jayaram

1 year 9 months ago

Hi, Yes,after reading values…

Hi,

Yes,after reading values from meter i am sending releaserequest and disconnection request.

Profile picture for user Kurumi

Kurumi

1 year 9 months ago

Hi, Don't send the release…

Hi,

Don't send the release message. Send just disconnect. That might help with some meters. Can you connect with GXDLMSDirector?

BR,
Mikko

jayaram

1 year 9 months ago

Hi, Tried by sending only…

Hi,
Tried by sending only disconnection request but still not working.

GXReplyData reply = new GXReplyData();
ReadDLMSPacket(Client.DisconnectRequest(), reply);

RX:7E A0 07 03 41 53 56 A2 7E

TX:

but if i try with guruxdlmsdirector UI its working.

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin