Skip to content

how to recover from an intermittent TCP timeout exception  #70

@tmcolby

Description

@tmcolby

What is the proper way to recover from a snap7 exception ISO : An error occurred during recv TCP : Connection timed out?

If I place a db_read() into a try/except clause to keep the application from aborting on TCP timeout, subsequent db_read() become out of sync. It seems somewhere the calls are queued. Probably in the native snap7 thread.

For example: If I have three locations I am reading from a PLC
3,260,4 contains value 100
3,272,4 contains value 200
1,104,4 contains value 300

-the first db_read(3,260,4) call successfully returns a value 100
-second db_read(3,272,4) call times out with TCP timeout exception
-third db_read(1,104,4) call will return value 200 (Not 300 like you would expect)
..
-a fourth call of db_read(3,260,4) will return the value from the third call above (300)

It seems the method calls get spooled into a queue and for every call that times out, the data returned will be delayed that many calls in the future.

Is there a way to throw away the buffer on a tcp timeout? Or is there some other philosophical approach I should be taking? It seems very dangerous to call a function with specific arguments and get the wrong data back. Thanks for any suggestions.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions