Comments (5)
🤖
嘿,@shangsheng!又见面了,希望一切都好!
为了让wechaty接入个人账号的发现服务,你需要在防火墙中开放你指定的端口。如果你没有指定端口,wechaty会自动选择一个空闲的端口。这个端口必须能够通过互联网公开访问。在这段代码中,如果没有指定端口,wechaty会默认选择8788端口。
wechaty的域名是通过WechatyToken的discover方法获取的,这个方法会返回一个包含主机名和端口的地址。
以下是相关的代码片段:
/**
* Puppet Service Server Port
*/
if (!port) {
log.info('Gateway', 'no `--port` specified, selecting random free Wechaty Puppet Service Server Port ...')
port = await getPort({
port: 8788,
})
}
log.info('Gateway', 'Wechaty Puppet Service Server Port: %d', port)
...
let address
while (true) {
log.info('Gateway', 'Registering Wechaty Puppet Token Gateway Service Discovery ...')
await new Promise(resolve => setTimeout(resolve, 1000))
address = await wechatyToken.discover()
if (address) {
log.info('Gateway', 'Registering Wechaty Puppet Token Gateway Service Discovery ... success')
break
}
log.info('Gateway', 'Registering Wechaty Puppet Token Gateway Service Discovery ... timeout')
}
console.info(`
The Wechaty Puppet Token Gateway Service Address is ${address.host}:${address.port}, please make sure it can be public accessed via the internet.
`)
请注意,这段代码中的${address.host}:${address.port}
就是wechaty的域名。你可以在这里查看完整的代码。
Sources
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.
If you want to continue the conversation, start your reply with @dosu-bot.
from wechaty.
🤖
Based on the provided context, it seems like the address
you're trying to generate is returning undefined
. This could be due to several reasons, and I'll try to provide some potential solutions.
Firstly, if the address
is supposed to be provided by the Wechaty Puppet being used, ensure that the Puppet is correctly initialized and started. The Puppet should be properly configured with any necessary tokens or configuration options that it needs to operate and generate or discover addresses.
Secondly, ensure that all necessary configuration options, including any tokens or keys needed to generate or discover the address
, are correctly provided when initializing the WechatyBase
instance. Missing or incorrect configuration could lead to the Puppet or other components not being able to function as expected.
Thirdly, if the address
is related to a specific feature of the Wechaty Puppet, verify that the Puppet you are using supports this feature. Not all Puppets have the same capabilities, and some might not support generating or discovering addresses in the way you expect.
Lastly, utilize the logging capabilities (log.verbose
, log.silly
, etc.) provided in the Wechaty framework to add more logging around the area where the address
is expected to be generated or discovered. This can help identify where the process is failing or if the address
is being set to undefined
at a specific point in the code.
To resolve the issue, you would typically start by ensuring that your Puppet is correctly initialized and that all required configurations are provided. If the problem persists, adding more detailed logging and debugging the code step by step to see where the address
might be getting lost or set to undefined
would be the next steps.
Regarding your questions about the WechatyToken.generate('insecure')
and WechatyToken.discover()
methods, I wasn't able to find specific implementations of these methods in the Wechaty codebase. It's possible that these methods are part of a different module or package, or they might be custom methods that you've added to your code. If you could provide more context about these methods, such as where they're defined or how they're supposed to work, I might be able to provide more specific advice.
I hope this helps! If you have any more questions or need further clarification, feel free to ask.
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.
If you want to continue the conversation, start your reply with @dosu-bot.
from wechaty.
🤖
From the code snippet you've provided, it seems like the address
variable is being assigned the result of the discover()
method on the wechatyToken
object. If address
is undefined
, it could mean that the discover()
method is not returning anything or is returning undefined
.
The WechatyToken.generate('insecure')
method seems to be generating a token, but without more context or documentation about this method, it's hard to say exactly what it does or what it should return. It's possible that if this method is not working as expected, it could be affecting the discover()
method and causing address
to be undefined
.
Here are some steps you can take to debug this issue:
-
Check the
WechatyToken.generate('insecure')
Method: Make sure this method is working as expected. You could try logging thetoken
variable to see what it contains. If it'sundefined
or not what you expect, that could be the source of the problem. -
Check the
discover()
Method: Similarly, check that thediscover()
method is working as expected. You could try logging theaddress
variable immediately after it's assigned to see what it contains. -
Check for Errors: Make sure there are no errors being thrown that you're not catching. You could add a
catch()
block to yourtokens()
function to catch and log any errors. -
Check Your Asynchronous Code: Your
tokens()
function is asynchronous, which means it returns a Promise. Make sure you're properly handling this Promise wherever you're callingtokens()
. If you're not waiting for the Promise to resolve before trying to useaddress
, that could be why it'sundefined
.
If none of these steps help, it would be helpful if you could provide more context or code. Specifically, the implementation of the WechatyToken.generate('insecure')
and discover()
methods would be useful to see.
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.
If you want to continue the conversation, start your reply with @dosu-bot.
from wechaty.
@dosu-bot async function tokens() {
let token = WechatyToken.generate('insecure')
console.log(token, 'token')
let wechatyToken = new WechatyToken(token);
let address = await wechatyToken.discover();
console.log(The Wechaty Puppet Token Gateway Service Address is ${address}:${address}, please make sure it can be public accessed via the internet.
)
}
tokens() 获取到address 为undefined
from wechaty.
可以指定域名吗?
from wechaty.
Related Issues (20)
- 我试图在房间中say消息有时候会报错,导致项目停止运行 HOT 3
- 重新扫码padlocal两三天了还没有人修复嘛,wechat bad request error: 你的应用版本过低,请升级至最新版本后再登录。点击“确定”后将跳转至最新版下载页面,登录不了咯, HOT 4
- 关于如何将ding-dong-bot.ts文件改成满足企业微信的demo HOT 7
- 企业微信遇到的问题 HOT 4
- 重新扫码padlocal两三天了还没有人修复嘛,wechat bad request error: 你的应用版本过低,请升级至最新版本后再登录。点击“确定”后将跳转至最新版下载页面,登录不了咯, HOT 6
- 我想监听群聊中其他人进入群聊的事件,是否有提供呢 HOT 5
- 为什么使用bot.Contact.findAll()方法查找到的联系人名称都是空呢 HOT 8
- 你的应用版本过低,请升级至最新版本后再登录。点击“确定”后将跳转至 最新版下载页面,依赖都是最新版的这个怎么解决呢 HOT 2
- 你的应用版本过低,请升级至最新版本后再登录。点击“确定”后将跳转至 最新版下载页面,依赖都是最新版的这个怎么解决呢? HOT 2
- 告诉我现在个人微信可以支持发送语音的所有puppet HOT 2
- Workpro 企业微信小程序消息发送失败
- 如何识别 引用 类型的消息,目前用text获取不到
- 【wechaty问题交流微信群】一起讨论,吐槽,解决wechaty中遇到的坑 HOT 1
- contact.friend()
- 什么时候可以支持消息的引用啊
- updating README
- PadLocal是不是带着小姨子跑路了 HOT 1
- 短时间多次调用room.say发送图片,发送间隔很长 HOT 4
- 你的应用版本过低,请升级击“确定”后将跳转至最新版下载页面。
- wechaty版本1.18+怎么获取用户唯一标识?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wechaty.