daiiniel / IEC60870-5-102

10 stars 2 forks source link

Problem trying start a session #1

Open agomezlucena opened 3 years ago

agomezlucena commented 3 years ago

Hi i'm trying to start a session when I connect, and always throw an IOException when trying to read the message packet i reicive, this is the stack trace:


   en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   en System.IO.Stream.ReadByte()
   en IEC60870_5_102.TransportLayer.MessagePacket.Read() en C:\Users\alex\Documents\IEC60870-5-102-master\IEC60870-5-102\TransportLayer\MessagePacket.cs:línea 72
   en IEC60870_5_102.TransportLayer.Transport.Receive() en C:\Users\alex\Documents\IEC60870-5-102-master\IEC60870-5-102\TransportLayer\Transport.cs:línea 96
   en IEC60870_5_102.LinkLayer.Link.Send(UInt16 linkDirection, Telegram request) en C:\Users\alex\Documents\IEC60870-5-102-master\IEC60870-5-102\LinkLayer\Link.cs:línea 117
   en IEC60870_5_102.LinkLayer.Link.RequestLinkStatus(UInt16 linkDirection) en C:\Users\alex\Documents\IEC60870-5-102-master\IEC60870-5-102\LinkLayer\Link.cs:línea 133
   en IEC60870_5_102.Master.RequestLink() en C:\Users\alex\Documents\IEC60870-5-102-master\IEC60870-5-102\Master.cs:línea 134
   en IEC60870_5_102.Master.StartSession() en C:\Users\alex\Documents\IEC60870-5-102-master\IEC60870-5-102\Master.cs:línea 142
   en ConsoleApp1.Program.Main(String[] args) en C:\Users\alex\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:línea 30```
daiiniel commented 3 years ago

Hey

What kind of connection are you using? What does the Exception message say?

agomezlucena commented 3 years ago

I use TcpClient class to connect to my meter and the message of the exception is the stacktrace that I passed before. Sorry for my english, but it isn't my mother language.

daiiniel commented 3 years ago

Yeah, I mean you should get a different message in the Message property of the IOException different than the stack trace.

agomezlucena commented 3 years ago

No se puede escribir datos de en la conexión de transporte: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder. I believe is a timeout but i don't sure, if that the cause of the exception

daiiniel commented 3 years ago

Yes, it could not connect to the remote endpoint. So is the IP Address correct? Are you using a host name instead? Is the remote endpoint under a firewall?

agomezlucena commented 3 years ago

I connect to that meter using a vpn, the meter don't have any firewall, i can make ping to the metter from cmd, its has about a second of delay more o less ¿maybe can be something like packet corruption? ¿or just it's a timeout for the speed of the connection?

daiiniel commented 3 years ago

I would recommend you trying to connect to that ip address and port using other tools such as telnet.

agomezlucena commented 3 years ago

i can connect without any problem using powerwatt. a part of that, i read the packets using wireshark, I see that a send a token when i create the conection, but when the metter make a response, it's reponse without any data, and also i modified timeouts, but that is not the problem.

daiiniel commented 3 years ago

I would suggest removing the line 142 a "Master.cs" where it says "this.RequestLink()" and would tell you to check the order of the parameters used in Master. Could you check that the same packets are sent by both "powerwatt" and the app?

image

daiiniel commented 3 years ago

Any update on this issue?

agomezlucena commented 3 years ago

nope.