Hello
I am trying to understand how to handle wrong password when i connect to meter with High authentication. There is my method:
public void ConnectToMeter()
{
GXReplyData reply = new GXReplyData();
SNRMRequest();
foreach (byte[] it in SecureClient.AARQRequest())
{
reply.Clear();
ReadDataBlock(it, reply);
}
SecureClient.ParseAAREResponse(reply.Data);
reply.Clear();
if (SecureClient.IsAuthenticationRequired)
{
foreach (byte[] it in SecureClient.GetApplicationAssociationRequest())
{
reply.Clear();
ReadDataBlock(it, reply);
}
SecureClient.ParseApplicationAssociationResponse(reply.Data);
}
}
When password is correct everything works fine. But when i tried to pass incorrect password exception has been thrown at this line:
SecureClient.ParseApplicationAssociationResponse(reply.Data);
With the message of "Unable to cast object of type 'System.Boolean' to type 'System.Byte[]'."
I checked reply.Data.Data array. There were these bytes: 03 00 C1 00 01 00 03 00.
Can you please explain how to handle incorrect password?
The same result when i tried
The same result when i tried to connect via Director.
Log from Director:
Log from Director:
15:12:39 Initializing Network connection.
15:12:40 Send SNRM request.
7E A0 07 03 61 93 69 47 7E
15:12:40
7E A0 20 61 03 73 05 9E 81 80 14 05 02 00 80 06 02 00 80 07 04 00 00 00 01 08 04 00 00 00 01 CE 6A 7E
15:12:40 Parsing UA reply succeeded.
15:12:40 Send AARQ request.
7E A0 4C 03 61 10 58 27 E6 E6 00 60 3E A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 6B 4F 58 17 6B 1B 0C 23 03 52 66 20 3F 61 72 30 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 5D FF FF B9 C0 7E
15:12:40
7E A0 58 61 03 30 07 51 E6 E7 00 61 4A A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 0E 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 CE 94 19 52 9D 2E C0 9E E0 DC A3 60 7B 54 1F D6 BE 10 04 0E 08 00 06 5F 1F 04 00 00 1E 1D 10 00 00 07 5A 99 7E
15:12:40 Parsing AARE reply succeeded.
15:12:40 Authenticating.
7E A0 2B 03 61 32 8D EB E6 E6 00 C3 01 C1 00 0F 00 00 28 00 00 FF 01 01 09 10 AB DD 12 0A 05 63 85 60 33 86 63 18 7D 3E 86 F8 62 D8 7E
15:12:41
7E A0 14 61 03 52 90 90 E6 E7 00 C7 01 C1 00 01 00 03 00 86 84 7E
15:12:41 Disconnect request
15:12:41
7E A0 07 61 03 73 77 46 7E
System.InvalidCastException: Unable to cast object of type 'System.Boolean' to type 'System.Byte[]'.
в Gurux.DLMS.GXDLMSClient.ParseApplicationAssociationResponse(GXByteBuffer reply)
в GXDLMSDirector.GXDLMSCommunicator.InitializeConnection(Boolean force)
в GXDLMSDirector.GXDLMSDevice.InitializeConnection()
в GXDLMSDirector.MainForm.Connect(Object sender, GXAsyncWork work, Object[] parameters)
Hi,
Hi,
If authentication fails, you don't return a boolean value. You must return an error. Something like this:
<ActionResponse>
<ActionResponseNormal>
<!-- Priority: High, ServiceClass: Confirmed, Invoke ID: 1 -->
<InvokeIdAndPriority Value="C1" />
<Result Value="ReadWriteDenied" />
</ActionResponseNormal>
</ActionResponse>
BR,
Mikko
I'm sorry. But the problem is
I'm sorry. But the problem is that i don't return anything like boolean value. I tried catch correct exception when password is incorrect. I am trying to understand why InvalidCastException has been thrown.
There is trace of connection to the meter when password is correct:
7E A0 07 03 61 93 69 47 7E
7E A0 20 61 03 73 05 9E 81 80 14 05 02 00 80 06 02 00 80 07 04 00 00 00 01 08 04 00 00 00 01 CE 6A 7E
7E A0 4C 03 61 10 58 27 E6 E6 00 60 3E A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 13 5E 19 40 6B 05 02 32 11 4C 23 67 4C 6C 0E 51 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 5D FF FF D4 2B 7E
7E A0 58 61 03 30 07 51 E6 E7 00 61 4A A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 0E 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 C0 7D A6 72 B1 1A 89 44 40 86 B6 3E CE 94 19 52 BE 10 04 0E 08 00 06 5F 1F 04 00 00 1E 1D 10 00 00 07 11 D0 7E
7E A0 2B 03 61 32 8D EB E6 E6 00 C3 01 C1 00 0F 00 00 28 00 00 FF 01 01 09 10 BE D1 9C A1 3B 53 F3 9C B3 1F 7C 92 89 D5 40 3B 06 D3 7E
7E A0 24 61 03 52 62 DC E6 E7 00 C7 01 C1 00 01 00 09 10 16 E4 E5 C6 7F 01 40 20 90 C4 98 39 9B 42 55 13 88 FA 7E
This one when the password is incorrect:
7E A0 07 03 61 93 69 47 7E
7E A0 20 61 03 73 05 9E 81 80 14 05 02 00 80 06 02 00 80 07 04 00 00 00 01 08 04 00 00 00 01 CE 6A 7E
7E A0 4C 03 61 10 58 27 E6 E6 00 60 3E A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 0D 6E 07 00 4D 34 16 2E 0C 12 5C 71 12 19 11 4C BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 5D FF FF CB A7 7E
7E A0 58 61 03 30 07 51 E6 E7 00 61 4A A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 0E 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 9D 2E C0 9E E0 DC A3 60 7B 54 1F D6 80 2A D4 ED BE 10 04 0E 08 00 06 5F 1F 04 00 00 1E 1D 10 00 00 07 C6 60 7E
7E A0 2B 03 61 32 8D EB E6 E6 00 C3 01 C1 00 0F 00 00 28 00 00 FF 01 01 09 10 BB 7B 5D 49 57 FA 9A 3A 52 83 6B D9 B7 E9 2E B2 C3 61 7E
7E A0 14 61 03 52 90 90 E6 E7 00 C7 01 C1 00 01 00 03 00 86 84 7E
7E A0 07 61 03 73 77 46 7E
System.InvalidCastException: Не удалось привести тип объекта "System.Boolean" к типу "System.Byte[]".
в Gurux.DLMS.GXDLMSClient.ParseApplicationAssociationResponse(GXByteBuffer reply)
в GXDLMSDirector.GXDLMSCommunicator.InitializeConnection(Boolean force)
в GXDLMSDirector.GXDLMSDevice.InitializeConnection()
в GXDLMSDirector.MainForm.Connect(Object sender, GXAsyncWork work, Object[] parameters)
Could you please list the reasons why this could happen?
Hi, Mikko!
Hi, Mikko!
Is it same as here with ByteBuffer?
http://gurux.fi/node/19755
Hi Dmitry,
Hi Dmitry,
This is the data that you are returning and it's wrong. You should return data as I described in #4.
BR,
Mikko
<ActionResponse>
<ActionResponseNormal>
<!-- Priority: High, ServiceClass: Confirmed, Invoke ID: 1 -->
<InvokeIdAndPriority Value="C1" />
<Result Value="Success" />
<ReturnParameters>
<Data>
<Boolean Value="false" />
</Data>
</ReturnParameters>
</ActionResponseNormal>
</ActionResponse>