Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special ssl socket, "no data" #2466

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pymodbus/client/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import socket
import time
from collections.abc import Callable
from ssl import SSLWantReadError

from pymodbus.client.base import ModbusBaseClient, ModbusBaseSyncClient
from pymodbus.exceptions import ConnectionException
Expand Down Expand Up @@ -235,10 +236,13 @@ def recv(self, size: int | None) -> bytes:
except ValueError:
return self._handle_abrupt_socket_close(size, data, time.time() - time_)
if ready[0]:
if (recv_data := self.socket.recv(recv_size)) == b"":
return self._handle_abrupt_socket_close(
size, data, time.time() - time_
)
try:
if (recv_data := self.socket.recv(recv_size)) == b"":
return self._handle_abrupt_socket_close(
size, data, time.time() - time_
)
except SSLWantReadError:
continue
data.append(recv_data)
data_length += len(recv_data)
time_ = time.time()
Expand Down