Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the correct way to connect to a Cassandra server ? #20

Open
yeyan opened this issue Feb 15, 2016 · 1 comment
Open

What is the correct way to connect to a Cassandra server ? #20

yeyan opened this issue Feb 15, 2016 · 1 comment

Comments

@yeyan
Copy link

yeyan commented Feb 15, 2016

Sorry for rising this as a issue, but it is a bit hard to figure out how to use this library.

root@b3e0266f401c:/# nodetool ring

Datacenter: SearchAnalytics
==========
Address     Rack        Status State   Load            Owns                Token                                       

172.17.0.2  rack1       Up     Normal  485.95 KB       ?                   -2758875854119677886     
{-# LANGUAGE OverloadedStrings #-}

import Data.UUID
import qualified Data.Text as T

import Database.Cassandra.CQL
import Control.Monad.IO.Class

import Data.Maybe

getOneSong :: Query style UUID (UUID)
getOneSong = query "select customer from status_by_customer where customer = ?"

test = do
    pool <- newPool [("172.17.0.2","")] "test_data" Nothing
    runCas pool $ do
        executeRows ANY getOneSong (fromJust $ fromString "c2cc10e1-57d6-4b6f-9899-38d972112d8c")

But I always get

failed to create a session due to temporary error (will retry) : NoAvailableServers

if I set the server to ("172.17.0.2", "b3e0266f401c"), the following error will rise:

failed to create a session due to permanent error (will rethrow) : getAddrInfo: does not exist (Servname not supported for ai_socktype)

And I am pretty sure I have exported all the port, that needed to connect to Cassandra, as my other programs are working fine with this docker.

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                                                                                      NAMES
b3e0266f401c        docker_cassandra    "/usr/local/bin/dse-e"   12 days ago         Up 50 minutes       4040/tcp, 7000/tcp, 7077/tcp, 7080-7081/tcp, 8012/tcp, 8090/tcp, 8983-8984/tcp, 9042/tcp, 9160/tcp, 9290/tcp, 10000/tcp, 50030/tcp, 50060/tcp, 61621/tcp   my-dse

Would you please show me an example that how to use this library to connect to Cassandra ?

@wrl314
Copy link
Collaborator

wrl314 commented Feb 15, 2016

The second entry in the Server tuple is a port number. So try
newPool [("172.17.0.2","9042")] "test_data" Nothing

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

No branches or pull requests

2 participants