问题描述
我已经从 github 克隆了这个项目:https://github.com/gustavohenrique/grpc-web-golang-vuejs/tree/master/backend。 我运行了前端和后端的项目。它有效。 该项目使用 grpcweb 包装服务器。 然后我写了一个小客户端来调用grpc服务器函数但是它不起作用。 我的客户端代码如下所示..
package main
import (
"context"
"fmt"
"io"
"log"
"time"
pb "backend/proto"
"google.golang.org/grpc"
)
func main() {
fmt.Println("Hello I'm a client")
conn,err := grpc.Dial("0.0.0.0:9000",grpc.WithInsecure())
if err != nil {
log.Fatalf("Could not connect: %v",err)
}
defer conn.Close()
c := pb.NewAccountServiceClient(conn)
)
doUnary(c)
}
func doUnary(c pb.AccountServiceClient) {
fmt.Println("do unary from the client")
req := &pb.User{
Email: "hh1212",Password: "23123",}
res,err := c.Create(context.Background(),req)
if err != nil {
log.Fatalf("error while calling RPC: %v",err)
}
log.Printf("Response from Greet: %v",res.GetEmail())
}
code = Unavailable desc = connection closed
exit status 1
grpcweb 包裹服务器的功能和普通的 grpc 服务器一样吗?或者我们有什么不同的东西可以从客户端进行通信? 戈兰
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)