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

dialing loopback with Insecure and Block hangs #2592

Closed
jba opened this issue Jan 23, 2019 · 1 comment
Closed

dialing loopback with Insecure and Block hangs #2592

jba opened this issue Jan 23, 2019 · 1 comment

Comments

@jba
Copy link

jba commented Jan 23, 2019

What version of gRPC are you using?

v1.18.0

What version of Go are you using (go version)?

go1.11.2

What operating system (Linux, Windows, …) and version?

Linux Debian 4.18.10

What did you do?

Dialed the loopback address with Insecure and Block.

package main

import (
    "context"
    "fmt"
    "log"
    "net"
    "time"

    "google.golang.org/grpc"
)

func main() {
    ctx := context.Background()
    l, err := net.Listen("tcp", "127.0.0.1:0")
    if err != nil {
        log.Fatal(err)
    }
    ctx, cancel := context.WithTimeout(ctx, 4*time.Second)
    defer cancel()
    conn, err := grpc.DialContext(ctx, l.Addr().String(), grpc.WithInsecure(), grpc.WithBlock())
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(conn)
}

What did you expect to see?

Immediate connection.

What did you see instead?

Timeout (hang).

> GRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=info go run grpc-hang.go
INFO: 2019/01/23 08:58:37 parsed scheme: ""
INFO: 2019/01/23 08:58:37 scheme "" not registered, fallback to default scheme
INFO: 2019/01/23 08:58:37 ccResolverWrapper: sending new addresses to cc: [{127.0.0.1:46625 0  <nil>}]
INFO: 2019/01/23 08:58:37 ClientConn switching balancer to "pick_first"
INFO: 2019/01/23 08:58:37 Subchannel Connectivity change to CONNECTING
INFO: 2019/01/23 08:58:37 pickfirstBalancer: HandleSubConnStateChange: 0xc00001f360, CONNECTING
INFO: 2019/01/23 08:58:41 Subchannel Connectivity change to SHUTDOWN
2019/01/23 08:58:41 context deadline exceeded

Works fine in v1.17.0.

@dfawley
Copy link
Member

dfawley commented Jan 23, 2019

This is due to #2565 as part of #2406.

If you want to consider the connection "ready" without actually being connected to a real gRPC server, you can use the environment variable GRPC_GO_REQUIRE_HANDSHAKE=off from now through our next release. After that, we will be removing support for this entirely. You should start a real grpc server in your tests if you need clients to believe they are successfully connected to a server.

Let us know if you have any questions or concerns.

@dfawley dfawley closed this as completed Jan 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants