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

web 协议 总是 提示断线 #107

Closed
Ran-Xing opened this issue Mar 31, 2022 · 12 comments
Closed

web 协议 总是 提示断线 #107

Ran-Xing opened this issue Mar 31, 2022 · 12 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@Ran-Xing
Copy link

亲爱的大佬,请问一下,就现在为止,该怎么搭配 purper
wecahty4u 好几年没维护了,wechaty4u 搭配的是 docker 0.65版本

最新版的 docker 镜像登录web版微信没有问题,但是 客户端提示连接失败,是否需要添加其他的参数呢?

Python 库 试用过了,还有提示,go 库 直接丢出报错,让我这个不怎么读代码的 菜鸟来说有点难受

@Ran-Xing Ran-Xing added bug Something isn't working question Further information is requested labels Mar 31, 2022
@dchaofei
Copy link
Collaborator

dchaofei commented Apr 1, 2022

你看下这个:wechaty/puppet-service#160

@Ran-Xing
Copy link
Author

Ran-Xing commented Apr 3, 2022

@dchaofei

Docker

export WECHATY_TOKEN="$(python3 -c 'import uuid;print(uuid.uuid4())')"
export tag=$2
export WECHATY_LOG=$3
export WECHATY_PUPPET=$4
export WECHATY_PUPPET_SERVER_PORT=$5
export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT=true
export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER=true

docker run -ti --rm \
    --name wechatBot \
    -e WECHATY_TOKEN \
    -e WECHATY_LOG \
    -e WECHATY_PUPPET \
    -e WECHATY_PUPPET_SERVER_PORT \
    -e WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT \
    -e WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER \
    -p "${WECHATY_PUPPET_SERVER_PORT}:${WECHATY_PUPPET_SERVER_PORT}" \
    -v "$(pwd)/Gateway:/bot" \
    wechaty/wechaty:"$tag"

Golang

	var bot = wechaty.NewWechaty(wechaty.WithPuppetOption(wp.Option{
		Token: "0f27d692-15bc-4b2e-aea3-956c5f18cae8"
		Timeout: 5 * time.Minute,
	}),
	)
	bot.OnScan(func(ctx *wechaty.Context, qrCode string, status schemas.ScanStatus, data string) {
		fmt.Printf("Scan QR Code to login: %v\nhttps://wechaty.github.io/qrcode/%s\n", status, qrCode)
	}).OnLogin(func(ctx *wechaty.Context, user *user.ContactSelf) {
		fmt.Printf("User %s logined\n", user.Name())
	}).OnMessage(onMessage).OnLogout(func(ctx *wechaty.Context, user *user.ContactSelf, reason string) {
		fmt.Printf("User %s logouted: %s\n", user, reason)
	})

	bot.DaemonStart()

log

2022/04/03 19:40:31 PuppetService Start()
2022/04/03 19:40:31 puppet start err:  PuppetService Start() rejection: startGrpcStream err:rpc error: code = Unavailable desc = connection closed
panic: PuppetService Start() rejection: startGrpcStream err:rpc error: code = Unavailable desc = connection closed

goroutine 1 [running]:
github.com/wechaty/go-wechaty/wechaty.(*Wechaty).DaemonStart(0x140001bc240?)
	/Users/xr/go/pkg/mod/github.com/wechaty/[email protected]/wechaty/wechaty.go:295 +0xd0
main.main()
	/Users/xr/IDEA/Go-Wechaty-BotDebug/Server/main.go:31 +0x124
exit status 2

@wordgao
Copy link

wordgao commented Apr 3, 2022

首先确认你的docker版本,不能大于0.68,否则无法使用,这个一般都是属于docker或版本不匹配导致获取不到服务器。
建议降低或使用0.65~0.67试试。

Disable TLS for Puppet Service Server
To disable server TLS:

Set WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER to true
Set options.tls.disable to true
Disable TLS for Puppet Service Client
To disable client TLS:

Set WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT to true
Set options.tls.disable to true

如果大于0.68的docker你就会涉及到这个问题,但不排除会有意外的BUG,所以使用go版的,推荐版本不要大于0.68.

目前测试稳定版本对接docker建议版本为0.65.

@Ran-Xing
Copy link
Author

Ran-Xing commented Apr 3, 2022

@windmemory 是的,使用的是v0.65
wechaty/wechaty:"$tag"

tag 给的值就是 0.65
方便换版本测试,所以用了个别名,写了个脚本

@wordgao
Copy link

wordgao commented Apr 3, 2022

如果连接不上,记得外网端口映射。否则GRPC无法和你的服务器对接,也会导致这个情况。

@Ran-Xing
Copy link
Author

Ran-Xing commented Apr 3, 2022

谢谢,我ncat 测试过了

@wordgao
Copy link

wordgao commented Apr 3, 2022

不过有个问题也是我感觉非常恶心的事情,某些参数已经export了,每次都要设置,程序运行之后,都会自动删除,非常恶心。

@Ran-Xing
Copy link
Author

Ran-Xing commented Apr 3, 2022

哈哈哈,我之前用python的时候看到一个好东西,当然我的仓库也愿意于你分享!但是写的不完善,就没开放

makefile

WECHATY_LOG = verbose
WECHATY_PUPPET = wechaty-puppet-wechat
WECHATY_PUPPET_SERVER_PORT = 30000
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER = true
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT = true
v = 0.65

.PHONY: all
all:
	@$(PWD)/.github/Makefile.sh all ${v} ${WECHATY_LOG} ${WECHATY_PUPPET} ${WECHATY_PUPPET_SERVER_PORT} ${WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER} ${WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT}
# 	wechaty/wechaty mybot.ts

.PHONY: updateToken
updateToken:
	@$(PWD)/.github/Makefile.sh updateToken

.PHONY: server
server:
	@cd Server;go run main.go

.PHONY: build
build:
	@cd Server;go mod download;go mod tidy

bash

#!/usr/bin/env bash

export WECHATY_TOKEN="$(python3 -c 'import uuid;print(uuid.uuid4())')"
export tag=$2
export WECHATY_LOG=$3
export WECHATY_PUPPET=$4
export WECHATY_PUPPET_SERVER_PORT=$5
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER=$6
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT=$7


function all () {
  initToken
  docker run -ti --rm \
	--name wechatBot \
  -e WECHATY_TOKEN \
	-e WECHATY_LOG \
	-e WECHATY_PUPPET \
	-e WECHATY_PUPPET_SERVER_PORT \
	-e WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER \
	-e WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT \
	-p "${WECHATY_PUPPET_SERVER_PORT}:${WECHATY_PUPPET_SERVER_PORT}" \
	-v "$(pwd)/Gateway:/bot" \
	wechaty/wechaty:"$tag"
    # 	wechaty/wechaty mybot.ts
}

function touchToken(){
		touch "$(pwd)/Gateway/${WECHATY_TOKEN}.memory-card.json" || exit
		echo  "WECHATY_TOKEN 创建完成! => $(pwd)/Gateway/${WECHATY_TOKEN}.memory-card.json"
		echo "WECHATY_TOKEN: ${WECHATY_TOKEN}"
	}

function deleteToken(){
		rm -rf "$(pwd)"/Gateway/*.memory-card.json
	}

function initToken(){
  if [[ "$(find "$(pwd)/Gateway/" -maxdepth 1 -name '*.memory-card.json' | wc -l | tr -d ' ')" -eq 0 ]]; then
    touchToken
  elif [[ "$(find "$(pwd)/Gateway/" -maxdepth 1 -name '*.memory-card.json' | wc -l | tr -d ' ')" -gt 1 ]]; then
    echo "Token 文件异常,正在初始化 Token ..."
    deleteToken
    touchToken
  else
    echo "Token 数量 1 个,没有问题! "
    file="$(basename $(ls $(pwd)/Gateway/*.memory-card.json || exit))"
    export  WECHATY_TOKEN="${file%%.*}"
    echo "WECHATY_TOKEN: ${WECHATY_TOKEN}"
  fi
}

function updateToken() {
    deleteToken
    touchToken
}

$*

使用方式 make v=0.65 make server

@wordgao
Copy link

wordgao commented Apr 3, 2022

为你点个赞!

@Ran-Xing
Copy link
Author

Ran-Xing commented Apr 3, 2022

12:03:23 VERB MemoryCard set(PUPPET_WECHAT, [object Object],[object Object],[object Object])
12:03:23 VERB MemoryCard <5143b040-1f8c-4f3e-a080-0e1b317e7c44> save() to StorageFile</wechaty/5143b040-1f8c-4f3e-a080-0e1b317e7c44.memory-card.json>
12:03:23 VERB StorageFile save() to /wechaty/5143b040-1f8c-4f3e-a080-0e1b317e7c44.memory-card.json

现在才发现,我映射错位置了,哈哈哈

@huan
Copy link
Member

huan commented Apr 4, 2022

@XRSec Congratulations!

Would you like to share your experiences by posting them to a Wechaty community blog post at https://wechaty.js.org/blog ? Because that will make it easy to be discovered by other Go Developers.

Please feel free to create a PR at https://github.com/wechaty/jekyll if you like.

@dchaofei
Copy link
Collaborator

问题已解决,关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants