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

grpc链接超时问题 #164

Open
Guwengo opened this issue May 9, 2024 · 2 comments
Open

grpc链接超时问题 #164

Guwengo opened this issue May 9, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Guwengo
Copy link

Guwengo commented May 9, 2024

docker我已经启动了使用puppet_padlocal也申请了token,也扫码正常了,部署再我的腾讯云服务器上,本地启动项目后提示grpc链接问题.超时!
我有个疑问环境变量我设置了token了,wechaty.NewWechaty()的时候他怎么知道我服务器地址,通过token去哪里查询码?谁知道大体原理和我说一下,捋一下思路.

下面是官网示例 使用puppet_padlocal链接云服务要单独设置什么吗?

package main

import (
	"fmt"
	"github.com/wechaty/go-wechaty/wechaty"
	"github.com/wechaty/go-wechaty/wechaty-puppet/schemas"
	"github.com/wechaty/go-wechaty/wechaty/user"
)

func main() {
	wechaty.NewWechaty().
		OnScan(func(context *wechaty.Context, qrCode string, status schemas.ScanStatus, data string) {
			fmt.Printf("Scan QR Code to login: %s\nhttps://wechaty.github.io/qrcode/%s\n", status, qrCode)
		}).
		OnLogin(func(context *wechaty.Context, user *user.ContactSelf) {
			fmt.Printf("User %s logined\n", user)
		}).
		OnMessage(func(context *wechaty.Context, message *user.Message) {
			fmt.Printf("Message: %s\n", message)
		}).DaemonStart()
}
@Guwengo Guwengo added the enhancement New feature or request label May 9, 2024
Copy link

dosubot bot commented May 9, 2024

To address the gRPC connection timeout issue when using puppet_padlocal with Wechaty in Go, it's important to understand how the server address is dynamically discovered using the token. The process involves making an HTTP GET request to https://api.chatie.io/v0/hosties/__token__ to retrieve the server address associated with your token. Ensure your token is correctly set in the WECHATY_PUPPET_SERVICE_TOKEN environment variable for this discovery process to work.

If you're encountering timeouts, check the following:

  • Your network allows HTTP requests to api.chatie.io and the discovered server address is reachable.
  • gRPC connection settings, including timeouts and retry policies, are appropriately configured.
  • TLS settings and other environment variables are correctly configured if required by your server's security requirements.

For customizing the gRPC connection timeout, you can use the WithTimeout(duration time.Duration) function to set a desired timeout period. Additionally, adjusting the GrpcReconnectInterval can help manage connection stability across varying network conditions.

If you continue to face issues, ensure all configurations are correct and consider network conditions or server response times as potential factors.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@huan
Copy link
Member

huan commented May 9, 2024

You are welcome to join the Wechaty Discord Server: there is a #go channel for discussing the Go Wechaty related questions.

Join Discord at https://discord.gg/7q8NBZbQzt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants