Valley.Net.Protocols.MeterBus icon indicating copy to clipboard operation
Valley.Net.Protocols.MeterBus copied to clipboard

TCP Connection (Binding) - only one requestData call works

Open ebsevon opened this issue 5 years ago • 1 comments

I am using the TcpBinding and interacting with a Moxa (TCP to Serial) converter to read one MBUS Device.

To intialisation of the MBusMaster I use following code: var serializer = new MeterbusFrameSerializer(); endpoint = new IPEndPoint(IPAddress.Parse(“192.168.100.41”), 4001); binding = new TcpBinding(endpoint,serializer); binding.Error += Binding_Error; binding.IoCompleted += Binding_IoCompleted; master = new MBusMaster(binding); master.Meter += Master_Meter;

Afterwards I am calling RequestData every five seconds: var response = master.RequestData((byte)MBusAdr, TimeSpan.FromSeconds(3)).Result as VariableDataPacket;

This works only for the first call. The second call rises following exception (Socket Exception):

AggregateException SocketException: A request to send or receive data was prevented because the socket is not connected and (when sending via a datagram socket with a sendto call) no address was specified

Is there anything wrong in my workflow or code?

ebsevon avatar May 27 '20 06:05 ebsevon

Seems like a bug, but I implemented my own TcpClient, to send and receive the raw data.

RJvdBerg avatar Oct 07 '22 09:10 RJvdBerg