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

A networked error on .read() will not make the client disconnected. #36

Closed
256dpi opened this issue Apr 13, 2016 · 5 comments
Closed

A networked error on .read() will not make the client disconnected. #36

256dpi opened this issue Apr 13, 2016 · 5 comments
Labels

Comments

@256dpi
Copy link

256dpi commented Apr 13, 2016

Hi again,

I found another issue while working on the arduino-mqtt library.

It looks like that errors from the read() method in the Network class do not traverse up in the client and set the internal flag to disconnected. This has the effect that clients, that never send any packets and only read from the connection, never change the internal "connected" flag if the underlying connection fails.

A fix would be to set the client to disconnected if any serious errors happen while reading from the underlying connection. That way, a future call to isConnected() would correctly return false.

@256dpi
Copy link
Author

256dpi commented Feb 20, 2017

Is somebody interested in looking at that?

@icraggs
Copy link
Contributor

icraggs commented Jul 7, 2017

I've updated the code that uses read() so that it correctly uses these return values:
-1: connection error, isConnected should then return false
0: zero bytes received within the time available, no connection error

0: the number of bytes received, no connection error

This works on Linux, I'm not sure about the Arduino read() implementation following these requirements properly.

@icraggs icraggs added the Arduino label Jul 7, 2017
@icraggs
Copy link
Contributor

icraggs commented Jul 14, 2017

I've added a test for disconnection which works on Linux. All that remains is to check it works on Arduino.

@ppescher
Copy link

@icraggs for Arduino see #205

@icraggs
Copy link
Contributor

icraggs commented Nov 30, 2023

Superseded by #205

@icraggs icraggs closed this as completed Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants