npgsql: Read with timeout is incompatible with SslStream
As @Emill wrote in gitter, our current synchronous implementation of Wait() will fail if a timeout is passed and SslStream is used, because:
SslStream assumes that a timeout along with any other IOException when one is thrown from the inner stream will be treated as fatal by its caller. Reusing a SslStream instance after a timeout will return garbage. An application should Close the SslStream and throw an exception in these cases.
See http://stackoverflow.com/questions/37177401/how-to-repeatedly-read-from-net-sslstream-with-a-timeout.
Note sure if there’s a good workaround for SslStream. For now, adding a check that throws NotSupportedException.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (22 by maintainers)
Commits related to this issue
- Add check for wait with timeout + SSL https://github.com/npgsql/npgsql/issues/1501 — committed to npgsql/npgsql by roji 7 years ago
- Fix check for wait with timeout + SSL #1501 — committed to cladisch/npgsql by cladisch 4 years ago
- Fix check for wait with timeout + SSL #1501 — committed to npgsql/npgsql by cladisch 4 years ago
- Fix check for wait with timeout + SSL #1501 (cherry picked from commit 572918fc3a94cf201ba947dac341d1a1de38f7b9) — committed to npgsql/npgsql by cladisch 4 years ago
- Fix check for wait with timeout + SSL #1501 (cherry picked from commit 572918fc3a94cf201ba947dac341d1a1de38f7b9) — committed to npgsql/npgsql by cladisch 4 years ago
I agree. We can just let it do the timeout on netstandard2.0 (i.e. not block it), and if the user is on .NET Framework it’s their problem…
Well then… great! So I guess just conditionally-compile the check for net461?
It actually does work - results.
I think we can just conditional-compile the check to only throw for TFMs where the timeout doesn’t work (i.e. net461).