Skip to content

Conversation

@erikd
Copy link
Contributor

@erikd erikd commented Apr 28, 2017

No description provided.

@erikd
Copy link
Contributor Author

erikd commented Apr 28, 2017

Wow, still getting:

https-client: Error_Packet "partial packet: expecting 16408 bytes, got: 2887"

even with this patch.

@erikd
Copy link
Contributor Author

erikd commented Apr 28, 2017

Just re-checked my test setup and I am very definitely getting this exception even with this patch.

However, this patch is useful and should probably be applied regardless.

@creichert
Copy link
Contributor

I'm definitely getting exceptions related to the PR. What needs to be done to get it merged?

@erikd I agree it should be merged either way. Do you have a URL which reproduces the Error_Packet exception? I'd love to help if possible

@erikd
Copy link
Contributor Author

erikd commented Jun 17, 2017

@creichert The only way I was able to reproduce this was by hammering an Amazon s3 bucket (100+ threads downloading parts of a 64+ gigabyte file) until the AWS rate limiter kicked in an started killing connections. Unfortunately this means that there is nothing as simple as a URL that reproduces the error I was chasing.

I also tried writing a simple warp-tls client to reproduce the AWS rate limiting behavior but that yielded nothing.

I still think using exceptions for error handling is a mistake.

@creichert
Copy link
Contributor

creichert commented Jun 17, 2017

@erikd thanks! too bad.

I do think that even if http-client wasn't using exceptions (and using something like Either) this bug would still potentially slip through because the underlying library is creating a new concrete data type for each exception, as opposed to rolling them into a sum type.

This may not help much, but here is a way to repro a Error_Protocol that this PR should fix by catching and wrapping:

#!/usr/bin/env stack
-- stack -v runghc --package connection --package http-client --package http-client-tls
{-# LANGUAGE OverloadedStrings #-}

import Prelude

import Network.HTTP.Client.TLS
import Network.HTTP.Client

main :: IO ()
main = do
    let (Just req) = parseUrlThrow "https://paste.debian.net"
    man <- newManager tlsManagerSettings
    _res <- httpLbs req man
    print "success"

tls-error-repro.hs: Error_Protocol ("bad SignatureRSA for ecdhparams",True,HandshakeFailure)


Edit To clarify, you have:

-- tls
instance Exception TLSError
instance Exception TLSException

-- connection
instance E.Exception LineTooLong
instance E.Exception HostNotResolved
instance E.Exception HostCannotConnect

So if a new one is added, it may be difficult to remember to check that, even if cabal version of the lib is incremented properly.

@erikd
Copy link
Contributor Author

erikd commented Jun 17, 2017

I'm not blaming http-client for using exceptions, I am blaming the underlying libraries. I think that if the underlying libraries hadn't used exceptions, then http-client wouldn't have had to handle them.

@erikd
Copy link
Contributor Author

erikd commented Jun 17, 2017

At work we have a large code base that always tries to catch exceptions as close as possible to their source and turn them into Eithers. It works really well until we have to use a library that allows exceptions to escape.

@snoyberg snoyberg merged commit 4d44b09 into snoyberg:master Jun 18, 2017
snoyberg added a commit that referenced this pull request Jun 18, 2017
@snoyberg
Copy link
Owner

Good call @creichert, and thanks @erikd. Released to Hackage.

@ocheron
Copy link
Contributor

ocheron commented Jun 18, 2017

I know this is not satisfactory, but see why Error_Protocol is thrown by tls instead of being wrapped inside HandshakeFailed, and will make a PR.

This for a different reason than haskell-tls/hs-tls#220. Exceptions occuring at a renegotiation handshake are simply not wrapped.

@creichert Your example has been very helpful, but must be using tls-1.3.9 or even earlier.

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