reddit
reddit copied to clipboard
TlsException when running getPosts
I'm trying to get some basic usage out of this library for a little bit and I'm getting a strange error when I try to use getPosts
. This is the only function I've really tried to do anything with, but here's what I'm doing.
{-# LANGUAGE OverloadedStrings #-}
import Reddit
main :: IO ()
main = runReddit "ayy" "lmao" getPosts >>= print
Sometimes this prints out a response, however sometimes I get this:
matt@crocomire ~/workspace/reddit-test
% cabal run reddit-test
Preprocessing executable 'reddit-test' for reddit-test-0.1.0.0...
Running reddit-test...
Left (HTTPError (TlsException (HandshakeFailed Error_EOF)))
Any idea why it might work sometimes but not other times? I've tried a few times and it seems random.
Oh I just tried it again and got Left (HTTPError (FailedConnectionException "api.reddit.com" 443))
instead. I have not recompiled in between working/not working times.
Does https://reddit.com/ work on your connection?
If it doesn't, it's probably an issue with Reddit's SSL (their servers are not the most reliable), but if it does, you could try this:
import Network.Connection
import Network.HTTP.Conduit
import Reddit
main =
withManagerSettings (mkManagerSettings (TLSSettingsSimple True False False) Nothing) $ \m ->
runRedditWith (def { connectionManager = Just m}) getPosts
This will disable certificate checking for the connection.
I can reliably get to HTTPS reddit, however I can't get a result with the API. I was able to use your method and runRedditAnon
to work though. I actually don't need to log in for anything I'm doing, so that works for me, but you probably want to look more into this.
which operating system / GHC version are you using?
I'm on Arch Linux using GHC 7.10.1
On Tue, Jul 21, 2015, 5:52 PM Intolerable [email protected] wrote:
which operating system / GHC version are you using?
— Reply to this email directly or view it on GitHub https://github.com/intolerable/reddit/issues/14#issuecomment-123487984.