连接到Click to Deploy Cassandra实例的问题

I'm trying to write data into Click To Deploy cassandra cluster using Golang gocql driver from a remote machine , But it fails to connect .

Here is my cassandra.yaml configuration ,

native_transport: true
listen_address: <public ip>
broadcast_address: <public ip>
rpc_address: 0.0.0.0
native_transport_port : 9042

And here is the Golang Code using which I'm remotely trying to connect

import (
    "fmt"
    "github.com/gocql/gocql"
)

func main() {
// connect to the cluster
    cluster := gocql.NewCluster(<public ip of cassandra nodes>)

    cluster.Keyspace = "demo"
    session, _ := cluster.CreateSession()
    defer session.Close()
    if err := session.Query("INSERT INTO users (lastname, firstname) VALUES ('Karthic', 'Rao')").Exec(); err != nil {
    fmt.Printf("ERror writing : ", err.Error())
    }
}

Here is the error , connect: failed to connect to "<public ip>:9042": dial tcp <public ip> :9042: i/o timeout

Any idea on how to fix this to make i/o on the cassandra nodes ?

You just need to open CQL native transport port (tcp:9042) on your GCE firewall to be able to connect to your cluster nodes remotely. You can use telnet <public ip> 9042 command to test if the port is open and listening. Also make sure the outgoing traffics to the port 9042 is not blocked on your remote network/firewall.

If the firewall is configured properly and you could telnet to the port but still receiving the mentioned error, then something is wrong with your gocql setup.