Skip to content

Conversation

@hmueller01
Copy link
Owner

Resolves knolleary#988.
Thanks to @ajlennon.

@TD-er
Copy link
Collaborator

TD-er commented Mar 17, 2025

Looks like a good catch/fix.
I wonder how many crashes there may have been due to this...

However there is still something odd:

        if (currentMillis - previousMillis >= this->socketTimeout * 1000UL) {
            return false;
        }

Why consider the socketTimeout as seconds here?

It isn't a bug, just odd as you now need to multiply it with 1000 every time you want to check it.

@CONSULitAS
Copy link
Collaborator

Why consider the socketTimeout as seconds here?

This has been introduced with 2.4 and is defined als 15 (commented as 15 seconds). Only used once.

https://github.com/search?q=repo%3Ahmueller01%2Fpubsubclient3%20MQTT_SOCKET_TIMEOUT&type=code

@hmueller01
Copy link
Owner Author

Your are right. It's really dumb to always multiply socketTimeout by 1000. Could do this once when we set it.
Question is, if a uint16_t with a max. of 65535 resulting in 65s is enough, or if in that case socketTimeout should change to uint32_t (aka unsigned long) as well ...

@hmueller01
Copy link
Owner Author

Looks like a good catch/fix. I wonder how many crashes there may have been due to this...

I think almost none, as we only read from the client, if the client signals available(). But never now what might happen and this it definitely the better implementation.

hmueller01 added a commit that referenced this pull request Mar 17, 2025
@TD-er TD-er self-assigned this Mar 18, 2025
Copy link
Collaborator

@TD-er TD-er left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hmueller01 hmueller01 merged commit 63070e1 into master Mar 18, 2025
1 check passed
@hmueller01 hmueller01 deleted the test-read-failure branch March 19, 2025 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants