Skip to content

Conversation

@savonarola
Copy link
Contributor

@savonarola savonarola commented Jul 23, 2025

After socket connection called with timeout, ssl:connect (the handshake) is called without timeout. But the handshake may last long and easily exceed the expected connect timeout. So we use ssl:connect/3 to limit the handshake time too.

@savonarola savonarola changed the title fix: respect connect timeout in ssl:connect Respect connect timeout in ssl:connect Jul 23, 2025
benoitc added a commit that referenced this pull request Jul 24, 2025
Measure elapsed time during TCP connection and pass remaining timeout to SSL handshake. Handle infinity timeout case and close socket on timeout.

Closes #776
@benoitc
Copy link
Owner

benoitc commented Jul 24, 2025

Thank you. I've updated your PR to take care of the infinity case in #781 . However i'm wondering if i's acually makes sense to do this since if we have now a socket why would we timeout ? Do you have any specific use case in mind?

benoitc added a commit that referenced this pull request Jul 24, 2025
Measure elapsed time during TCP connection and pass remaining timeout to SSL handshake. Handle infinity timeout case and close socket on timeout.

Closes #776
@savonarola
Copy link
Contributor Author

savonarola commented Jul 24, 2025

Hello! I hit this case when testing an app under emulation of network data loss. The connection process took unexpectedly long time to fail.

Since the handshake involves network operations, this seems to be a possible situation in a real environment. We connect but sometimes lose the subsequent packets, causing ssl:connect to take longer then expected.

@benoitc benoitc closed this in #781 Jul 24, 2025
@savonarola savonarola deleted the fix-ssl-connect-timeout branch July 24, 2025 16:52
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.

2 participants