We are using EDM meter over TCP/IP ie. interface as Wrapper. As per vendor he says that, the meter can support 3 active client connections.
Our application is multithreaded, so in a thread we connect meter, takes data and close it. While doing this we have observer that while initiating connection there is source and destination port. if the source port is changing as an when request is send to meter it consider new connection to meter and opens new client and so on. after it reaches max client count it blocks new connection to meter for inactivity time out.
we try to set it to minimum 3-5 seconds but after some time it blocks the connect for long time.
Can you please suggest me how to handled this issue. sharing you wireshark logs.
I believe that you have a problem with your code. Check why the source port is changing. That should be the same at all times. It might be easier to find the reason if you try with one client.
Just for you information, I have the smart meters also with the interface type as Wrapper. this meters are working with same logger only encryption part is additional.
In my application I am creating thread for each time it connect to meter, takes data and disconnect the meter. this is the life cycle of thread.
while next time for same meter, application initiate new thread follow the life cycle and exit. so on for all the meters configured in logger. This is working fine for other interface type also. No 2 or more thread can connect to singe meter at the same time. so if considering this it may be possible that source port change during communication.
Please suggest how handle this port changing issue. can we fix source port for each meters.
as you suggested, I have tried by using GuruxDirector it works fine for single meter at time ( connect, takes data and disconnect).
Hi,
Hi,
Are you calling disconnect before closing the connection?
Are you calling the Close-method for the media component?
BR,
Mikko
Hi Mikko,
Hi Mikko,
I am calling below function after every data fetch request. also in final block I check for the reader , client and media to close or assign null.
public void Close()
{
if (Media != null && Client != null)
{
try
{
GXReplyData reply = new GXReplyData();
try
{
//Release is call only for secured connections.
//All meters are not supporting Release and it's causing problems.
if (Client.InterfaceType == InterfaceType.WRAPPER ||
(Client.InterfaceType == InterfaceType.HDLC && Client.Ciphering.Security != Security.None))
{
ReadDataBlock(Client.ReleaseRequest(), reply);
}
}
catch (Exception ex)
{
//All meters don't support Release.
//Console.WriteLine("Release failed. " + ex.Message);
}
reply.Clear();
ReadDLMSPacket(Client.DisconnectRequest(), reply);
Media.Close();
}
catch
{
}
Media = null;
Client = null;
}
}
Hi,
Hi,
I believe that you have a problem with your code. Check why the source port is changing. That should be the same at all times. It might be easier to find the reason if you try with one client.
BR,
Mikko
Hi Mikko,
Hi Mikko,
Just for you information, I have the smart meters also with the interface type as Wrapper. this meters are working with same logger only encryption part is additional.
In my application I am creating thread for each time it connect to meter, takes data and disconnect the meter. this is the life cycle of thread.
while next time for same meter, application initiate new thread follow the life cycle and exit. so on for all the meters configured in logger. This is working fine for other interface type also. No 2 or more thread can connect to singe meter at the same time. so if considering this it may be possible that source port change during communication.
Please suggest how handle this port changing issue. can we fix source port for each meters.
as you suggested, I have tried by using GuruxDirector it works fine for single meter at time ( connect, takes data and disconnect).