Coder Social home page Coder Social logo

Comments (5)

dosubot avatar dosubot commented on June 2, 2024 2

🤖

嘿,@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.

dosubot avatar dosubot commented on June 2, 2024 2

🤖

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.

dosubot avatar dosubot commented on June 2, 2024 2

🤖

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:

  1. Check the WechatyToken.generate('insecure') Method: Make sure this method is working as expected. You could try logging the token variable to see what it contains. If it's undefined or not what you expect, that could be the source of the problem.

  2. Check the discover() Method: Similarly, check that the discover() method is working as expected. You could try logging the address variable immediately after it's assigned to see what it contains.

  3. Check for Errors: Make sure there are no errors being thrown that you're not catching. You could add a catch() block to your tokens() function to catch and log any errors.

  4. 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 calling tokens(). If you're not waiting for the Promise to resolve before trying to use address, that could be why it's undefined.

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.

shangsheng avatar shangsheng commented on June 2, 2024

@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.

AnsonCode avatar AnsonCode commented on June 2, 2024

可以指定域名吗?

from wechaty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.