gcloud datastore emulator does not work with go client

607 views
Skip to first unread message

Nicolae Vartolomei

unread,
Jun 22, 2016, 5:42:06 AM6/22/16
to google-cloud-sdk
launching with gcloud emulators cloud-datastore-emulator start and then connecting with go client throws a bunch of errors on the client side. However it works without any problem when connecting to a real cloud datastore instance.

any ideas?

2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50176->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50178->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50180->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50182->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50184->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50186->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50188->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50190->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50192->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50194->127.0.0.1:8346: read: connection reset by peer.
2016/06/22 12:18:43 transport: http2Client.notifyError got notified that the client transport was broken read tcp 127.0.0.1:50196->127.0.0.1:8346: read: connection reset by peer.


Zachary Newman

unread,
Jun 22, 2016, 6:39:02 AM6/22/16
to Nicolae Vartolomei, Google Cloud Developers
Sorry you're running into trouble here. Adding the <google-c...@googlegroups.com> list, which may have more insight for you.

--
You received this message because you are subscribed to the Google Groups "google-cloud-sdk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-cloud-sdk.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sdk/d20221be-7aec-4553-924c-3019f39519ad%40googlegroups.com.

Adam (Cloud Platform Support)

unread,
Jun 25, 2016, 1:33:03 PM6/25/16
to google-cloud-sdk, nvart...@gmail.com, google-c...@googlegroups.com
It looks like this may be related to the lack of gRPC support in the current gcloud emulator. You should be able to use the standalone gcd emulator as a workaround.
Message has been deleted

Nicolae Vartolomei

unread,
Jun 27, 2016, 4:09:43 AM6/27/16
to google-cloud-sdk, ara...@google.com, google-c...@googlegroups.com
Using standalone gcd, found here: https://github.com/GoogleCloudPlatform/gcloud-golang/issues/224 (standalone gcd emulator)

I get the same errors

Jun 27 08:05:47.684 kartinki INFO [web.go:63] Running on :8080 using 8 processes
2016/06/27 11:05:47 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.
2016/06/27 11:05:47 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.
2016/06/27 11:05:47 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.
2016/06/27 11:05:47 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.
2016/06/27 11:05:47 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.
2016/06/27 11:05:47 transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.

Jonathan Amsterdam

unread,
Jun 27, 2016, 4:22:42 PM6/27/16
to google-cloud-sdk, ara...@google.com, google-c...@googlegroups.com
Let's start with something basic: making sure you can grpc.Dial the emulator. I assume you've started the emulator with something like

    ./gcd.sh start /tmp/datastore-emulator
  

Now name this program grpc-dial.go:
--------
package main

import (
        "fmt"
        "log"
        "os"
        "time"

)

func main() {
        addr := os.Getenv("DATASTORE_EMULATOR_HOST")
        if addr == "" {
                log.Fatal("DATASTORE_EMULATOR_HOST not set")
        }
        fmt.Printf("dialing %s\n", addr)
        conn, err := grpc.Dial(addr, grpc.WithInsecure())
        if err != nil {
                log.Fatal(err)
        }
        time.Sleep(2 * time.Second)
        conn.Close()
}
--------
Then run it with

    DATASTORE_EMULATOR_HOST=localhost:8080 go run grpc-dial.go 

(That assumes you're using the 'sh' or 'bash' shells.)

When I do that, I see

    dailing localhost:8080

and 2 seconds later, the program terminates. Just to compare, when I start the gcloud datastore emulator and to the same with its port, I see exactly the error you do.

Nicolae Vartolomei

unread,
Jul 4, 2016, 11:54:44 AM7/4/16
to google-cloud-sdk, ara...@google.com, google-c...@googlegroups.com
This is what I see too.

Jonathan Amsterdam

unread,
Jul 5, 2016, 9:49:11 AM7/5/16
to google-cloud-sdk, ara...@google.com, google-c...@googlegroups.com
(Sorry for the delay in responding — American holiday.)

What this shows is that you can successfully dial the standalone emulator. Now let's try it with the datastore client. I call this ds-client-connect.go:
---------------------------
package main

import (
        "fmt"
        "golang.org/x/net/context"
        "google.golang.org/cloud/datastore"
        "log"
        "time"
)

func main() {
        ctx := context.Background()
        client, err := datastore.NewClient(ctx, "YOUR_PROJECT_ID")
        if err != nil {
                log.Fatal(err)
        }
        fmt.Println(client)
        time.Sleep(5 * time.Second)
}
---------------------------

Replace YOUR_PROJECT_ID with your project ID. Now run

DATASTORE_EMULATOR_HOST=localhost:8080 go run ds-client-connect.go

and it should wait five seconds and terminate without any error messages. 

If that works for you, then we've shown that you can connect to the standalone emulator with the datastore client. There is probably something wrong with your configuration that is causing problems with your code. Are you sure that the DATASTORE_EMULATOR_HOST environment variable is set correctly?

Sachin Kotwani

unread,
Oct 7, 2016, 10:42:58 AM10/7/16
to Jonathan Amsterdam, google-cloud-sdk, ara...@google.com, google-c...@googlegroups.com, Chris Sells, Dan McGrath, Patrick Costello
Was this ever resolved? If not, could you try starting the datastore emulator with the following command?

gcloud beta emulator datastore start --no-legacy

The non-legacy version allows users to use gRPC, which is required for Go. 

--
You received this message because you are subscribed to the Google Groups "google-cloud-sdk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sdk+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages