Closed latkins closed 8 years ago
Most likely something is actually wrong with your connection.
We throw away all information about the problem when the request fails. https://github.com/dmjio/hackernews/blob/master/src/Web/HackerNews/Client.hs#L133
This means that you would have to figure out what's wrong with connection yourself. To do that you can use curl or run something like withOpenSSL $ openConnectionSSL ctx "hacker-news.firebaseio.com" 443
from ghci and see what exception it throws.
I think we should provide information about what went wrong rather than just giving ConnectionError
, but it might be not simple with ghcjs (unless we define our own error description)
Hmm, so running
ctx <- baselineContextSSL
x <- withOpenSSL $ openConnectionSSL ctx "hacker-news.firebaseio.com" 443
print x
gives Segmentation fault: 11. This seems to happen before the ctx <- baselineContextSSL. Guess I will try and work out what is going on!
On Mon, 16 Nov 2015 at 18:03 Konstantin Zudov notifications@github.com wrote:
Most likely something is actually wrong with your connection.
We throw away all information about the problem when the request fails. https://github.com/dmjio/hackernews/blob/master/src/Web/HackerNews/Client.hs#L133
This means that you would have to figure out what's wrong with connection yourself. To do that you can run something like withOpenSSL $ openConnectionSSL ctx "hacker-news.firebaseio.com" 443 from ghci and see what exception it throws.
I think we should provide information about what went wrong rather than just giving ConnectionError, but it might be not simple with ghcjs (unless we define our own error description)
— Reply to this email directly or view it on GitHub https://github.com/dmjio/hackernews/issues/16#issuecomment-157120959.
Looks like a problem with some native dependencies
So actually it looks I just had to initialise openssl.
main = withOpenSSL $ do
ctx <- baselineContextSSL
x <- withOpenSSL $ openConnectionSSL ctx "hacker-news.firebaseio.com" 443
print x
This gives:
Host: hacker-news.firebaseio.com
Which would suggest something else is happening.
Scratch that, the original function is now working. How very odd.
Which would suggest something else is happening.
I guess it means that the connection was established successfully
Okay, I understand now. It seems that the failed attempts were all on the Ask sub board. Individual comments, stories etc, all work perfectly. Is this as it should be (e.g. 10027102 fails with getItem) ?
@latkins, yea, if you don't use withOpenSSL
the HsOpenSSL
package will segfault :smile:
Just to clarify:
main :: IO ()
main = do
a <- hackerNews (getItem $ ItemId 10572982)
print a
b <- hackerNews (getItem $ ItemId 10575270)
print b
returns:
Left NotFound
Right (ItemStory (Story {storyBy = "kevinchen", storyId = StoryId 10575270, storyKids = [10576385,10575656,10576293,10576021,10575794,10575711,10575512], storyScore = 80, storyTime = 2015-11-16 16:22:24 UTC, storyTitle = "Intel 4004 mask design released, converted to SVG file", storyType = "story", storyUrl = "http://www.4004.com/2015-news.html", storyDeleted = False, storyDead = False}))
@latkins cross check 10572982
w/ a different hacker news API. If it's the same issue, it's not on our end.
@dmjio:
Using the python firebase library to get 10572982 gives:
{u'by': u'sharmi',
u'descendants': 7,
u'id': 10572982,
u'kids': [10573135, 10575020, 10574117, 10573862],
u'score': 18,
u'text': u'Hi,\n I am using Introduction to Probability by Joe Blitzstein and Jessica Hwang to learn probability by self study but I would like to have an additional book for problems practice. Can you suggest one that has solutions available for students? It would be nice if it is free but it is ok otherwise.',
u'time': 1447655872,
u'title': u'Ask HN: What is the best book to learn probability through self study?',
u'type': u'story'}
@latkins this is fixed in 1.0
, on hackage
Not sure what I might be doing wrong, but:
results in:
Any idea why this might be?