diff --git a/tap.go b/tap.go index d7e67e8..61c84c8 100644 --- a/tap.go +++ b/tap.go @@ -12,7 +12,6 @@ import ( "github.com/songgao/packets/ethernet" "github.com/songgao/water" "google.golang.org/grpc" - "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials/insecure" ) @@ -40,10 +39,6 @@ func (cli *RPCClient) connect() { return } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - defer cancel() - - log.Println(conn.WaitForStateChange(ctx, connectivity.Idle)) cli.conn = conn go cli.run() time.Sleep(time.Millisecond) @@ -59,6 +54,7 @@ func (cli *RPCClient) run() { }() c := gen.NewFrameServiceClient(cli.conn) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() stream, err := c.SendFrames(ctx) @@ -144,7 +140,7 @@ func (nc *NetCard) runRead() { framesBytes = append(framesBytes, []byte(rframe)) } - println(len(framesBytes)) + log.Println(len(framesBytes)) if len(framesBytes) > 0 { if nc.cli.conn == nil { nc.cli.connect()