Skip to content

Instantly share code, notes, and snippets.

@glasserc
Last active November 1, 2015 18:37
Show Gist options
  • Save glasserc/3f867fb9538d64fcd63d to your computer and use it in GitHub Desktop.
Save glasserc/3f867fb9538d64fcd63d to your computer and use it in GitHub Desktop.
many-tls: TlsExceptionHostPort (HandshakeFailed (Error_Packet_unexpected "Alert [(AlertLevel_Fatal,BadRecordMac)]" " expected: change cipher"))
import Control.Concurrent
import Control.Concurrent.STM
import Control.Monad
import Network.HTTP.Client
import Network.HTTP.Client.TLS
numThreads = 250
main = do
manager <- newManager tlsManagerSettings {managerConnCount=1000}
request <- parseUrl "https://www.google.com/"
chan <- newTChanIO
replicateM_ numThreads $ forkRequest request manager chan
allResponses <- readNTChan numThreads chan
print allResponses
forkRequest request manager chan =
forkIO $
withResponse request manager $ \resp -> atomically $
writeTChan chan $ responseStatus resp
readNTChan num chan = atomically $
replicateM num $ readTChan chan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment