Valley.Net.Protocols.MeterBus
Valley.Net.Protocols.MeterBus copied to clipboard
TCP Connection (Binding) - only one requestData call works
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?
Seems like a bug, but I implemented my own TcpClient, to send and receive the raw data.