python-wechaty-getting-started icon indicating copy to clipboard operation
python-wechaty-getting-started copied to clipboard

how to use puppet-xp Gateway with python

Open suguer opened this issue 3 years ago • 22 comments

I run puppet-xp Gateway successly , but when i try to connect my local gateway with python , it failed token is successly no docker

2022-03-03 14:51:56,037 - Wechaty - INFO - on() listen event <scan> with <<function on_scan at 0x000002B163195430>>
2022-03-03 14:51:56,037 - Wechaty - INFO - on() listen event <login> with <<function on_login at 0x000002B166203040>>
2022-03-03 14:51:56,037 - Wechaty - INFO - on() listen event <message> with <<function on_message at 0x000002B162EFDD30>>
2022-03-03 14:51:56,073 - PuppetService - WARNING - there are endpoint<127.0.0.1:8788> and token<insecure_156f31cd-8629-4a4d-a6ee-9bab5ccf3aea>, and the endpoint will be used for service ...
2022-03-03 14:51:56,073 - Wechaty - INFO - init_puppet_event_bridge() <<wechaty_puppet_service.puppet.PuppetService object at 0x000002B1663064C0>>
2022-03-03 14:51:56,073 - Wechaty - INFO - initPuppetEventBridge() puppet.on(dong) (listenerCount:1) registering...
2022-03-03 14:51:56,073 - Wechaty - INFO - initPuppetEventBridge() puppet.on(error) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(heart-beat) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(ready) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - receive <reset> event <%s>
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(reset) (listenerCount:0) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(friendship) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(login) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(logout) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(message) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-invite) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-join) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-leave) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(room-topic) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - initPuppetEventBridge() puppet.on(scan) (listenerCount:1) registering...
2022-03-03 14:51:56,074 - Wechaty - INFO - starting puppet ...
2022-03-03 14:51:56,074 - PuppetService - INFO - init puppet ...
2022-03-03 14:51:56,092 - PuppetService - INFO - starting the puppet ...
2022-03-03 14:51:56,104 - Wechaty - ERROR - The network is not good, the bot will try to restart after 60 seconds.
But here are some suggestions for you:
* 查看token是否可用?(过期或协议不可用)
* docker 服务是否正常启动?
* python-wechaty bot 是否正常启动?
* python-wechaty bot 是否能ping通docker服务?
* 由于版本细节问题,目前python-wechaty 支持最好的wechaty镜像为:[wechaty/wechaty:0.65](https://hub.docker.com/layers/wechaty/wechaty/0.65/images/sha256-d39b9fb5dece3a8ffa88b80a8ccfd916be14b9d0de72115732c3ee714b0d6a96?context=explore)

I suggest that you should follow the template code from: https://wechaty.readthedocs.io/zh_CN/latest/ to avoid the unnecessary bugs.

suguer avatar Mar 05 '22 01:03 suguer

set WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER=true

bigbrother666sh avatar Mar 05 '22 02:03 bigbrother666sh

when i set WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER=true , npm start and run python. gateway show something error

10:19:02 WARN PuppetServer start() TLS disabled: INSECURE!
10:19:09 INFO IoClient wechat. logged in
10:20:24 ERR PuppetServiceImpl stop() eventStreamManager is not busy?
10:20:24 WARN PuppetLoginMixin logonoff() is deprecated, use `isLoggedIn` instead:
Error
    at PuppetXp.logonoff (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/login-mixin.js:86:101)
    at PuppetXp.onStop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/dist/esm/src/puppet-xp.js:260:18)
    at PuppetXp.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/state-switch/dist/esm/src/service-ctl/service-ctl.js:108:28)
    at PuppetXp.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/service-mixin.js:25:25)
    at stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:1085:45)
    at Object.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleUnary (C:\Users\staff\AppData\Roaming\npm\node_modules\wechaty\node_modules\@grpc\grpc-js\build\src\server.js:674:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
10:20:24 INFO IoClient 苏.79. logged out
file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/event-stream-manager.js:69
        if (this.puppet.readyIndicator.value()) {
                                       ^

TypeError: Cannot read properties of undefined (reading 'value')
    at EventStreamManager.start (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/event-stream-manager.js:69:40)
    at event (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:287:32)
    at Object.event (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleServerStreaming (C:\Users\staff\AppData\Roaming\npm\node_modules\wechaty\node_modules\@grpc\grpc-js\build\src\server.js:696:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

suguer avatar Mar 05 '22 02:03 suguer

What version of the wechaty are you using with the npm install ? (current the newest version is 1.13.22)

Please upgrade it by using npm install -g wechaty@next if you are not the newest version and try again.

huan avatar Mar 05 '22 02:03 huan

wechaty -v 1.13.22 it is the newest version, but also failed

suguer avatar Mar 05 '22 02:03 suguer

error is different

10:46:53 ERR PuppetServiceImpl grpcError() stop() rejection: Timeout after 15000 ms
GError: Timeout after 15000 ms
    at Function.from (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/gerror/dist/esm/src/gerror/gerror.js:80:23)
    at Timeout._onTimeout (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/gerror/dist/esm/src/timeout-promise/timeout-promise.js:19:42)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
10:46:53 WARN ServiceCtl<PuppetServiceMixin> start() found that is stopping, waiting stable ... (max 5 seconds)
10:46:58 WARN ServiceCtl<PuppetServiceMixin> start() found that is stopping, waiting stable ... timeout
10:46:58 WARN PuppetXp onStart() this.#sidecar exists? will be replaced by a new one.
10:46:59 INFO IoClient wechat. logged in
10:49:36 ERR PuppetServiceImpl stop() eventStreamManager is not busy?
10:49:36 WARN PuppetLoginMixin logonoff() is deprecated, use `isLoggedIn` instead:
Error
    at PuppetXp.logonoff (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/login-mixin.js:86:101)
    at PuppetXp.onStop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/dist/esm/src/puppet-xp.js:260:18)
    at PuppetXp.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/state-switch/dist/esm/src/service-ctl/service-ctl.js:108:28)
    at PuppetXp.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/service-mixin.js:25:25)
    at stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:1085:45)
    at Object.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleUnary (C:\Users\staff\AppData\Roaming\npm\node_modules\wechaty\node_modules\@grpc\grpc-js\build\src\server.js:674:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
10:49:36 INFO IoClient wechat. logged out

suguer avatar Mar 05 '22 02:03 suguer

I believe you also need the latest version of the wechaty-puppet-xp

What version do you have? 1.7.1 is the newest version, and it needs to be installed as global too:

npm install -g wechaty-puppet-xp@next

huan avatar Mar 05 '22 02:03 huan

yes,i do it , wechaty and wechat-puppet-xp Does the python code also need to be adjusted? python
os.environ['WECHATY_PUPPET'] = "wechaty-puppet-service" os.environ['WECHATY_PUPPET_SERVICE_ENDPOINT'] = "127.0.0.1:8788" os.environ['WECHATY_PUPPET_SERVICE_TOKEN'] = "insecure_18fbabcd-ca2b-44da-82fc-030d1a0cb07d" os.environ['WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT'] = "true"

npm error

11:09:33 ERR PuppetServiceImpl stop() eventStreamManager is not busy?
11:09:33 WARN PuppetLoginMixin logonoff() is deprecated, use `isLoggedIn` instead:
Error
    at PuppetXp.logonoff (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/login-mixin.js:86:101)
    at PuppetXp.onStop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/dist/esm/src/puppet-xp.js:203:18)
    at PuppetXp.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/state-switch/dist/esm/src/service-ctl/service-ctl.js:108:28)
    at PuppetXp.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/service-mixin.js:25:25)
    at stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:1085:45)
    at Object.stop (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleUnary (C:\Users\staff\AppData\Roaming\npm\node_modules\wechaty\node_modules\@grpc\grpc-js\build\src\server.js:674:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
11:09:33 INFO IoClient 苏.79. logged out
11:09:33 INFO IoClient 苏.79. logged in
file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/event-stream-manager.js:216
                    throw new Error('eventName ' + eventName + ' unsupported!');
                          ^

Error: eventName post unsupported!
    at EventStreamManager.connectPuppetEventToStreamingCall (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/event-stream-manager.js:216:27)
    at EventStreamManager.start (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/event-stream-manager.js:41:41)
    at event (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:287:32)
    at Object.event (file:///C:/Users/staff/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleServerStreaming (C:\Users\staff\AppData\Roaming\npm\node_modules\wechaty\node_modules\@grpc\grpc-js\build\src\server.js:696:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

suguer avatar Mar 05 '22 03:03 suguer

i found wechaty-puppet-xp@next version is 1.7.1 wechaty-puppet-xp@latest is 1.10.19 but both failed

suguer avatar Mar 05 '22 03:03 suguer

Could you please post the log messages of the next version?

huan avatar Mar 05 '22 04:03 huan

sorry, i don't know how to post the log messages , what should i do, I am glad to do it

suguer avatar Mar 05 '22 04:03 suguer

Just like this one:

https://github.com/wechaty/python-wechaty-getting-started/issues/74#issuecomment-1059674608

With the exactly version you are using with both wechaty and the puppet-xp

huan avatar Mar 05 '22 04:03 huan

you can reference here 【腾讯文档】如何在本地使用免费的wechaty-puppet-xy协议 https://docs.qq.com/doc/DQ0VJUWtSVE1Mb2JJ hope helpful

bigbrother666sh avatar Mar 05 '22 04:03 bigbrother666sh

window env wechaty-puppet-xp 1.10.19 wechaty 1.13.22

python 3.9 wechaty 0.8.34 wechaty-grpc 0.20.19 wechat-puppet 0.4.0

suguer avatar Mar 05 '22 05:03 suguer

@WukongZeming A blog post on the Wechaty website would be greatly valuable for publishing this article!

huan avatar Mar 05 '22 05:03 huan

@suguer Have you tried the [email protected] ?

huan avatar Mar 05 '22 05:03 huan

ok. i try again with a new machine

suguer avatar Mar 05 '22 05:03 suguer

no, [email protected] is failed , i try to setup in a new machine

suguer avatar Mar 05 '22 05:03 suguer

@WukongZeming A blog post on the Wechaty website would be greatly valuable for publishing this article!

I don't know how to do that. I've tried to find a PR entrance on the wechaty.org github page. but it asked where to merge .... i'am puzzled with that

bigbrother666sh avatar Mar 05 '22 05:03 bigbrother666sh

Here has a docs for PR might be helpful to you: https://wechaty.js.org/docs/contributing/pulls

huan avatar Mar 05 '22 05:03 huan

@WukongZeming It's a sad result , i run again in a new host config is same +-- [email protected] extraneous | -- [email protected] extraneous -- [email protected] extraneous +-- [email protected] extraneous | -- [email protected] deduped +-- [email protected] extraneous | -- [email protected] deduped +-- [email protected] extraneous -- [email protected] extraneous -- [email protected] deduped

15:11:43 ERR PuppetServiceImpl stop() eventStreamManager is not busy?
15:11:43 WARN PuppetLoginMixin logonoff() is deprecated, use `isLoggedIn` instead:
Error
    at PuppetXp.logonoff (file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/login-mixin.js:86:101)
    at PuppetXp.onStop (file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/dist/esm/src/puppet-xp.js:260:18)
    at PuppetXp.stop (file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/state-switch/dist/esm/src/service-ctl/service-ctl.js:108:28)
    at PuppetXp.stop (file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/wechaty-puppet-xp/node_modules/wechaty-puppet/dist/esm/src/mixins/service-mixin.js:25:25)
    at stop (file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:1085:45)
    at Object.stop (file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleUnary (C:\Users\Administrator\AppData\Roaming\npm\node_modules\wechaty\node_modules\@grpc\grpc-js\build\src\server.js:674:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

suguer avatar Mar 05 '22 08:03 suguer

the working config is as follow: npm@ C:\Users\bigbr\AppData\Roaming\npm +-- [email protected] | -- [email protected] -- [email protected] +-- [email protected] | +-- [email protected] deduped | -- [email protected] | -- [email protected] deduped +-- [email protected] | -- [email protected] deduped -- [email protected] deduped

maybe you should try npm install -upgrade [email protected] and npm install -upgrade wechaty-puppet-xp hope helpful

bigbrother666sh avatar Mar 07 '22 00:03 bigbrother666sh

i just tried, but it does not work for me. it so sad

suguer avatar Mar 08 '22 01:03 suguer