wechaty / dotnet-wechaty

.NET Wechaty is a Conversational SDK for Chatbot Makers Written in C#
Apache License 2.0
80 stars 29 forks source link

System.Exception: 获取hostie gateway 对应的主机信息异常 #31

Closed forconz closed 2 years ago

forconz commented 3 years ago

能不能把*.proto文件披露下,我们可以自己实现Grpc对应的逻辑

fail: Wechaty.Module.Puppet.WechatyPuppet[0]
      StartGrpcClient() exception,Grpc Retry Surplus Count 3
      System.Exception: 获取hostie gateway 对应的主机信息异常
         at Wechaty.Module.PuppetService.GrpcPuppet.DiscoverHostieIp(String token) in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\modules\Wechaty.Module.PuppetService\GrpcPuppet.cs:line 74
         at Wechaty.Module.PuppetService.GrpcPuppet.StartGrpcClient() in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\modules\Wechaty.Module.PuppetService\GrpcPuppet.cs:line 97
         at Wechaty.Module.PuppetService.GrpcPuppet.StartGrpc() in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\modules\Wechaty.Module.PuppetService\GrpcPuppet.cs:line 322
fail: Wechaty.Wechaty[0]
      start failed.
      System.Exception: puppetClient had not initialized
         at Wechaty.Module.PuppetService.GrpcPuppet.StopGrpcClient() in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\modules\Wechaty.Module.PuppetService\GrpcPuppet.cs:line 170
         at Wechaty.Module.PuppetService.GrpcPuppet.StartGrpc() in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\modules\Wechaty.Module.PuppetService\GrpcPuppet.cs:line 337
         at Wechaty.Module.Puppet.WechatyPuppet.Start() in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\modules\Wechaty.Module.Puppet\WechatyPuppet.cs:line 202
         at Wechaty.Wechaty.Start() in D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\Wechaty\Wechaty.cs:line 430
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: D:\Projects\Test\dotnet-wechaty\dotnet-wechaty-net5.0\dotnet-wechaty-net5.0\src\Wechaty.Getting.Start\bin\Debug\netcoreapp5.0
Jesn commented 3 years ago

wechaty gateway 更新到最新版本,并且关闭SSL,目前SSL验证还有点问题

export WECHATY_LOG="verbose"
export WECHATY_PUPPET="wechaty-puppet-padlocal"
export WECHATY_PUPPET_PADLOCAL_TOKEN="puppet_padlocal_XXXX"
export WECHATY_PUPPET_SERVICE_NO_SSL_UNSAFE_CLIENT=true
export WECHATY_PUPPET_SERVER_PORT="9001"
export WECHATY_TOKEN="set your wechaty gateway token"

docker run \
  --name wechaty_puppet_service_token_gateway-no-ssl \
  -e WECHATY_LOG \
  -e WECHATY_PUPPET \
  -e WECHATY_PUPPET_PADLOCAL_TOKEN \
  -e WECHATY_PUPPET_SERVER_PORT \
  -e WECHATY_TOKEN \
  -e WECHATY_PUPPET_SERVICE_NO_SSL_UNSAFE_CLIENT \
  -p "$WECHATY_PUPPET_SERVER_PORT:$WECHATY_PUPPET_SERVER_PORT" \
  wechaty/wechaty:next

docker gateway 运行起来后,通过https://api.chatie.io/v0/hosties/puppet_padlocal_XXX 检查IP是否为你当前的Gateway对应的IP,如果不是的话,在初始化Puppet的时候指定Endpoint,eg: https://localhost:9010 ,这里需要注意下必须使用https

 var PuppetOptions = new Module.Puppet.Schemas.PuppetOptions()
 {
     Token = _configuration["WECHATY_PUPPET_SERVICE_TOKEN"],
     Endpoint="https://localhost:9010"
 };
 bot = new Wechaty(PuppetOptions);
Jesn commented 2 years ago

wechaty grpc: https://github.com/wechaty/grpc/tree/main/proto/wechaty ,

chsarp wechaty grpc build https://github.com/wechaty/grpc/tree/main/polyglot/csharp/Wechaty.Grpc