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

Fix HTTP Client with SSL #3216

Merged
merged 1 commit into from Sep 16, 2019

Conversation

@me-no-dev
Copy link
Member

commented Sep 16, 2019

No description provided.

@me-no-dev me-no-dev merged commit 4ce2cc3 into master Sep 16, 2019
20 checks passed
20 checks passed
Build Arduino IDE Tests 0
Details
Build Arduino IDE Tests 1
Details
Build Arduino IDE Tests 2
Details
Build Arduino IDE Tests 3
Details
Build Arduino IDE Tests 4
Details
Build Arduino IDE Tests 5
Details
Build Arduino IDE Tests 6
Details
Build Arduino IDE Tests 7
Details
Build Arduino IDE Tests 8
Details
Build Arduino IDE Tests 9
Details
Build Arduino IDE Tests 10
Details
Build Arduino IDE Tests 11
Details
Build Arduino IDE Tests 12
Details
Build Arduino IDE Tests 13
Details
Build Arduino IDE Tests 14
Details
Build Arduino IDE Tests 15
Details
Build Arduino IDE Tests 16
Details
Build Arduino IDE Tests 17
Details
Build PlatformIO Tests
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@me-no-dev me-no-dev deleted the ssl-fix branch Sep 16, 2019
@Jeroen88

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2019

@me-no-dev Why so difficult? Why where the ::connect() methods with timeout introduced in the first place? Wouldn't it be far better to call the parent class WiFiClient::setTimeout() method?

I did not have time to check it, but I think there is a nasty error in start_ssl_client() that might be the root cause of the problems. In this line and the next, not a pointer and a sizeof() an int should be passed, but a pointer and a sizeof a struct timeval. I think because the first element of the struct is a timeout in seconds, the error was never discovered...

struct timeval tv; tv.tv_sec = 0; tv.tv_usec = timeout * 1000; if(lwip_setsockopt(SO_RCVTIMEO, &tv, sizeof(struct timeval)) < 0) { return -1; } if(lwip_setsockopt(SO_SNDTIMEO, &tv, sizeof(struct timeval)) < 0) { return -1; } I

In the above code a timeout in milliseconds is set, but, since WiFiClient::setTimeout() is in seconds, I strongly believe (just because this method existed earlier than ::setHandshakeTimeout(), which is in milliseconds) that the connect() timeout parameter should be in seconds. But, even better: remove these methods and call the parent class setTimeout()

Also, because the timeouts are messy between WiFiClient, HTTPClient and the socket timeout that the timeout parameters should be renamed to show in what unit they are, so not int32_t timeout but int32_t timeout_milliseconds or something like that.

Also I think that this line could also better be replaced by the parent class WiFiClient::setNoDelay()

I did not test any of this, I did not even try to code it, so maybe I am completely wrong...

@me-no-dev

This comment has been minimized.

Copy link
Member Author

commented Sep 17, 2019

this will do for now :) rewrite of both clients is in order ;) Also is integrating with the official Arduino API. Timeouts are good ;) we need them but they can be implemented better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.