Fix setting MQTT socket buffer size with WebsocketWrapper (#117672)

This commit is contained in:
J. Nick Koston
2024-05-19 14:09:21 -10:00
committed by GitHub
parent 99565bef27
commit ac3321cef1
2 changed files with 45 additions and 0 deletions

View File

@ -540,6 +540,14 @@ class MQTT:
def _increase_socket_buffer_size(self, sock: SocketType) -> None:
"""Increase the socket buffer size."""
if not hasattr(sock, "setsockopt") and hasattr(sock, "_socket"):
# The WebsocketWrapper does not wrap setsockopt
# so we need to get the underlying socket
# Remove this once
# https://github.com/eclipse/paho.mqtt.python/pull/843
# is available.
sock = sock._socket # noqa: SLF001
new_buffer_size = PREFERRED_BUFFER_SIZE
while True:
try: