Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Websockets Library (Noah Sluss)
2. Re: Websockets Library (Dimitri DeFigueiredo)
----------------------------------------------------------------------
Message: 1
Date: Sun, 23 Aug 2015 15:06:13 -0700
From: Noah Sluss <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Websockets Library
Message-ID:
<CAM_Gs8epi-z7F0CYwP=qfKRF2uNq=7nqljyb4p2ux99qy_y...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello,
I've been trying to use the WebSockets library to connect to the
coinbase feed. The library seems to be doing something behind the scenes
that I'm not expecting.
Here is my code:
> {-# LANGUAGE ViewPatterns #-}
> {-# LANGUAGE OverloadedStrings #-}
>
> import Data.Text
> import Data.Text.Encoding (decodeUtf8)
> import Network.WebSockets
> import qualified Data.ByteString.Lazy as LBS
>
> main :: IO ()
> main = runClient "ws-feed.exchange.coinbase.com" 8080 "/"
> handleConnection
> handleConnection connection = do
> send connection initSub
> let loop = do
> priceMsg <- receiveDataMessage connection
> print priceMsg
> loop
>
> initSub :: Message
> initSub = DataMessage $ Text "{\"type\":\"subscribe\",
> \"product_id\":\"BTC-USD\"}"
When I run this, I get a print out showing a malformed response exception
with a Moved permanently message. Now, it also shows the location that I
was trying to connect to, which is: "https://ws-feed.exchange.coinbase.com/
".
This isn't right, because the websocket feed uses the wss:// protocol
rather than https://. i've tried changing the url to be "wss://
ws-feed.exchange.coinbase.com/", but when I try that, dns resolution fails.
If I had to guess, I could imagine that it tries to look for "https://wss://
ws-feed.exchange.coinbase.com", which would obviously not work. I'm
wondering if there is a way within the library to change the protocol that
client uses. If there is, it doesn't seem to be documented.
Any insights as to what's going on here would be incredibly helpful.
Thanks,
Noah
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150823/814c1a72/attachment-0001.html>
------------------------------
Message: 2
Date: Sun, 23 Aug 2015 16:19:36 -0600
From: Dimitri DeFigueiredo <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Websockets Library
Message-ID: <[email protected]>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
Hi Noah,
I haven't looked at your code, but this library parses that same feed.
(It's also on Hackage)
https://github.com/AndrewRademacher/coinbase-exchange
You may want to either use it or take a look at the code.
Cheers,
Dimitri
Em 23/08/15 16:06, Noah Sluss escreveu:
> Hello,
>
> I've been trying to use the WebSockets library to connect to the
> coinbase feed. The library seems to be doing something behind the
> scenes that I'm not expecting.
>
> Here is my code:
>
> {-# LANGUAGE ViewPatterns #-}
> {-# LANGUAGE OverloadedStrings #-}
>
> import Data.Text
> import Data.Text.Encoding (decodeUtf8)
> import Network.WebSockets
> import qualified Data.ByteString.Lazy as LBS
>
> main :: IO ()
> main = runClient "ws-feed.exchange.coinbase.com
> <http://ws-feed.exchange.coinbase.com>" 8080 "/" handleConnection
> handleConnection connection = do
> send connection initSub
> let loop = do
> priceMsg <- receiveDataMessage connection
> print priceMsg
> loop
>
> initSub :: Message
> initSub = DataMessage $ Text "{\"type\":\"subscribe\",
> \"product_id\":\"BTC-USD\"}"
>
>
> When I run this, I get a print out showing a malformed response
> exception with a Moved permanently message. Now, it also shows the
> location that I was trying to connect to, which is:
> "https://ws-feed.exchange.coinbase.com/".
>
> This isn't right, because the websocket feed uses the wss:// protocol
> rather than https://. i've tried changing the url to be
> "wss://ws-feed.exchange.coinbase.com/
> <http://ws-feed.exchange.coinbase.com/>", but when I try that,
> dns resolution fails. If I had to guess, I could imagine that it tries
> to look for "https://wss://ws-feed.exchange.coinbase.com
> <http://ws-feed.exchange.coinbase.com>", which would obviously not
> work. I'm wondering if there is a way within the library to change the
> protocol that client uses. If there is, it doesn't seem to be
> documented.
>
> Any insights as to what's going on here would be incredibly helpful.
>
> Thanks,
> Noah
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150823/6210b3ff/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 86, Issue 19
*****************************************