Closed Handfeger closed 2 years ago
I have never observed this before. Could you try reproducing either directly on your Windows machine or on a Linux machine ? Sometimes virtual machines can behave in a surprising way.
The code was working fine using a Windows machine with the National Instruments ivi adapter. I tried installing pyvisa-py on there which resulted in version conflicts for pyvisa that I couldn't solve yet. I will update you on this matter.
If you install the latest pyvisa-py, you need the latest pyvisa. Let me know if you run into more issues.
Ok I testet it now on Windows and it works fine. So it is most likely related to Linux or the Virtual Machine. I still need to understand why this does not happen to all sockets. If anyone finds this Problem in future this resource might help. I will also share my fix when I have found the error finally.
Thanks for sharing your findings @Handfeger
Ok so this is the fault of Docker for Windows and there seems to be no way to fix it right now. Only way I found to fix this issue right now is to catch the broken pipe error and reestablish the connection and then to repeat the visa command. This happens to all devices, connected to any type of socket.
Thanks for the follow up ! Hopefully it will help others.
Found a way to tell Unix sockets to send keep alive packets to the client, so you never run into the 5 minute timeout. This should also bring more stability to other systems, which they didn't need. Feel free to close this issue again, if you don't think this is the job of pyvisa-py
which it probably isn't.
When not using the device for 5 Minutes it closes the connection resulting in a
BrokenPipeError: [Errno 32] Broken pipe
when trying to send queries. I run this code in a Linux Docker container on a Windows host using the WSL2 backend.When constantly using the connection this problem does not appear. Only after idling for 5 Minutes.
To Reproduce
I already tried to set the socket to
keep_alive
by insertingself.sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
intopyvisa-py.protocols.rcp.RawTCPClient
inside the connect method with no success.Output of
pyvisa-info