I try to create a simple golang client to connect to eventstoredb but it fails to connect.
Eventstoredb is started with docker :
docker run --name eventstore-node -it -p 2113:2113 -p 1113:1113 -e EVENTSTORE_RUN_PROJECTIONS=All -e EVENTSTORE_START_STANDARD_PROJECTIONS=true eventstore/eventstore --insecure --enable-atom-pub-over-http
I am using the EventStore-Client-Go library (https://github.com/EventStore/EventStore-Client-Go)
The source code to connect is this
package main
import (
"context"
"fmt"
"log"
"github.com/EventStore/EventStore-Client-Go/client"
"github.com/EventStore/EventStore-Client-Go/direction"
"github.com/EventStore/EventStore-Client-Go/position"
)
func main() {
ctx := context.Background()
connString := "esdb://127.0.0.1:1113"
conf, err := client.ParseConnectionString(connString)
if err != nil {
log.Fatal(err)
}
conf.DisableTLS = true
conf.SkipCertificateVerification = true
cli, err := client.NewClient(conf)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", conf)
if cli == nil {
log.Fatal("CLI IS NIL")
}
err = cli.Connect()
if err != nil {
log.Fatal(err)
}
messages, err := cli.ReadAllEvents(ctx, direction.Forwards, position.StartPosition, 1, true)
if err != nil {
log.Fatal(err)
}
fmt.Println(messages)
}
When I execute the program, I have the following error:
&{Address:127.0.0.1:1113 GossipSeeds:[] DisableTLS:true NodePreference: Username: Password: SkipCertificateVerification:true Connected:false MaxDiscoverAttempts:10 DiscoveryInterval:100 GossipTimeout:5 DnsDiscover:false}
2020/11/01 11:20:21 Failed to construct read client. Reason: rpc error: code = Unavailable desc = connection closed
Does anyone have an idea of the problem ?