Start server

go run *.go

Start client api

cd example/client
go run *.go

# Access over web browser

# Access grpc over generated stub
# http://localhost:18080

# Access grpc service over https
# http://localhost:18080/test

Tried using IP instead

const (
	address = "127.0.0.1:3443" // Not working
)

// Response
// rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type "text/plain; charset=utf-8"
// but works under http://localhost:18080/test

Tried using Localhost instead

const (
	address = "localhost:3443" // Not working
)

// Same response
// rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type "text/plain; charset=utf-8"
// but works under http://localhost:18080/test

Both cases still able be reproduced, same case with other credential method.

cred, _ := credentials.NewClientTLSFromFile("./server.crt", "localhost")

// Expected same response.
// rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type "text/plain; charset=utf-8"
// still works under http://localhost:18080/test

Now test with standard grpc implementation with different port:

# Uncomment this line on `example/client/main.go`
go s.serveGrpc(serv, handler)

Then update the address in client example

const (
	address = "localhost:50051"
)

// then using insecure credential
cred := insecure.NewCredentials()
interceptors := []grpc.DialOption{
    grpc.WithTransportCredentials(cred),
    grpc.WithBlock(),
}

It works.