Closed johntaiii closed 7 years ago
方便提供下代码和系统环境嘛?
@johntaiii
你好,就是示例代码
#coding: utf-8
from wechat_sender import Sender
Sender().send("Hello From Wechat Sender")
运行环境是Python 2.7.10 macOS10.12.5
谢谢
在另一个脚本运行 listen 启动 wechat_sender 服务了嘛?
from wxpy import *
from wechat_sender import *
bot = Bot()
listen(bot)
# 之后 wechat_sender 将持续运行等待接收外部消息
像这样 @johntaiii
我是直接在wxpy里listen的
你这个 wxpy 的脚本也是跑在本机的嘛?如果不在同一台机器上需要给 Sender 指定 host @johntaiii
都是在本机上跑的..
很奇怪,看起来像是 wechat_Sender 服务没有跑起来,你给 listen 所在的脚本加上
import logging
logging.basicConfig(level=logging.DEBUG)
然后再跑看看是不是报错了
wxpy跑起来后又挂了....
你 listen 的端口被占用了,换一个 listen(port=xxxx) 在 listen 里加这个参数端口号找个空闲的
File "wx_sender.py", line 3, in
Sender().send("Hello From Wechat Sender")
File "/Library/Python/2.7/site-packages/wechat_sender/sender.py", line 60, in send
res = requests.post(url, data=data, timeout=self.timeout)
File "/Library/Python/2.7/site-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, kwargs)
File "/Library/Python/2.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 513, in request
resp = self.send(prep, send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 623, in send
r = adapter.send(request, kwargs)
File "/Library/Python/2.7/site-packages/requests/adapters.py", line 516, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=10245): Read timed out. (read timeout=5)