Menu

Unabled to connect to PLC after a few/many hours

Help
Bojo
2016-09-10
2020-11-01
  • Bojo

    Bojo - 2016-09-10

    In an application that uses libnodave I have a problem: after a period of time the application can't connect to the PLC anymore and all solution I trying to reconnect fail. It happens on one specific environment.

    The appliation uses multiple PLC-connections at the same time in multiple threads. One of connections read a toggle bit in which I try to detect a disconnected PLC. Another one polls the PLC and reads several DB's. I use a seperate connection for writing to the PLC. And finally i have a separte connection the read large pieces of data when that is directly needed.

    Some times when i try to connect to the PLC the connection fails with an exception:
    System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at Libnodave.daveConnection.daveConnectPLC(IntPtr dc)
    at Libnodave.daveConnection.connectPLC()

    That connection is "new", defined in a local scope and the creation and connect of the connection are two lines of code after eachother. It is defined in a try-catch-block and I used all possiblities that I know to close and clean up the connection when I'm done. When an exception occurs I even force the garbage collector to clean up (don't know if that helps, but it helped for one day). This day the application could not create an connection anymore, every connection ended up with an access violation exception after the connect.

    I used a fix from "Alex" where the pseudoPointer destroyed and there I get the excepton:
    System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at Libnodave.pseudoPointer.daveFree(IntPtr p)
    at Libnodave.pseudoPointer.Finalize()
    And then all bad things start.

    After a restart of the application all things are good again. And then it happens again, sometime 10 en sometime more than 24 hours later.

    We think there is a bad network connection and that connection sometimes fails, but not a completely lost connection. But I'm not sure, I cannot reproduce the issue.

    Does someone has an idea how I can troubleshoot this issue? Or can some tell how he/she manages to create new connetions (and close them correctly) over and over again? I'm out of ideas so every thing helps.

     
  • Anonymous

    Anonymous - 2017-09-19
    Post awaiting moderation.
  • Anonymous

    Anonymous - 2019-03-31
    Post awaiting moderation.
  • Arturas

    Arturas - 2020-11-01

    I have exactly same problem. Did you find a solution?

     
  • Anonymous

    Anonymous - 2021-08-19
    Post awaiting moderation.

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.