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

登录失败 start login with type: QrLogin #2691

Closed
tieguowei opened this issue May 10, 2024 · 9 comments
Closed

登录失败 start login with type: QrLogin #2691

tieguowei opened this issue May 10, 2024 · 9 comments

Comments

@tieguowei
Copy link

padlocal网关一直循环输出
07:57:15 VERB StateSwitch on(pending) <- (false)
07:57:15 INFO [PuppetPadlocal] start login with type: QrLogin
07:57:30 VERB EventStreamManager grpcEmit(EVENT_TYPE_HEARTBEAT[1], {"data":"heartbeat@padlocal"})
07:57:36 VERB StateSwitch off(pending) <- (false)
07:57:36 VERB StateSwitch off(true) <- (pending)

我的机器人启动后就一直在等待:
2024-05-10 15:56:04,504 - Wechaty - INFO - starting puppet ...
2024-05-10 15:56:04,504 - PuppetService - INFO - init puppet ...
2024-05-10 15:56:04,505 - PuppetService - INFO - starting the puppet ...
2024-05-10 15:56:04,589 - PuppetService - INFO - puppet has started ...
2024-05-10 15:56:04,589 - PuppetService - INFO - listening the event from the puppet ...

请问是什么原因?

Copy link

dosubot bot commented May 10, 2024

It looks like your bot is stuck in the login process, which could be due to a few different issues. Here's a more focused approach to troubleshoot and potentially resolve the problem:

  1. Check the Scan Event Handling: Make sure the scan event is properly handled to display or log the QR code URL. If this step is missed, the bot won't proceed beyond the waiting state because it's expecting a QR code scan that never happens.

  2. Verify Network and Connectivity: Ensure there are no network issues preventing the bot from communicating with the Padlocal gateway. This includes checking your internet connection and ensuring that the Padlocal servers are reachable.

  3. Look for Errors: Pay attention to any errors that might be emitted by the error event. These could provide valuable insights into what's going wrong during the login process.

  4. Configuration and Authentication: Double-check your bot's configuration and authentication details. Incorrect settings or expired tokens could be the reason behind the login failure.

  5. Padlocal Gateway Issues: Since the problem involves the Padlocal gateway, consider any specific issues or limitations with their service, including checking for any service outages or updates that might affect the login process.

  6. Update Dependencies: Ensure you're using the latest version of the wechaty-puppet-padlocal package. Outdated dependencies can lead to unexpected issues during the login process.

By focusing on these areas, you should be able to narrow down the cause of the issue. If the problem persists, consulting the Padlocal gateway documentation or reaching out to their support might provide further guidance.

Details

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.

To continue the conversation, mention @dosu.

@tieguowei
Copy link
Author

tieguowei commented May 10, 2024

@dosu这是我网关的代码
WX20240510-161720@2x

这是机器人代码:
import os
import asyncio

os.environ['token'] = "1fe5f846-6789-401d-b20c-9089076f5-8965446"
os.environ['endpoint'] = "127.0.0.1:9001"

from urllib.parse import quote

from wechaty import (
Contact,
FileBox,
Message,
Wechaty,
ScanStatus,
)

async def on_message(msg: Message):
print("======="+msg.text())
"""
Message Handler for the Bot
"""
if msg.text() == 'ding':
await msg.say('dong')

    file_box = FileBox.from_url(
        'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/'
        'u=1116676390,2305043183&fm=26&gp=0.jpg',
        name='ding-dong.jpg'
    )
    await msg.say(file_box)

async def on_scan(
qrcode: str,
status: ScanStatus,
data,
):
"""
Scan Handler for the Bot
"""
print('on_scan
============Status: ' + str(status))
print('View QR Code Online: https://wechaty.js.org/qrcode/' + quote(qrcode))

async def on_login(user: Contact):
"""
Login Handler for the Bot
"""
print(user)
# TODO: To be written

async def main():

bot = Wechaty()

bot.on('scan',      on_scan)
bot.on('login',     on_login)
bot.on('message',   on_message)

await bot.start()

print('[Python Wechaty] Ding Dong Bot started.')

asyncio.run(main())

Copy link

dosubot bot commented May 10, 2024

It seems like the primary issue you're encountering with your bot getting stuck at the QR login step could be related to several factors, including configuration, network, or compatibility issues. Here are some targeted steps to help you troubleshoot and hopefully resolve the problem:

  1. Verify Padlocal Token and Configuration: Double-check that your Padlocal token (WECHATY_PUPPET_PADLOCAL_TOKEN) is correctly set in your environment variables and that it hasn't expired. An incorrect or expired token is a common cause for login failures.

  2. Check Wechaty and Padlocal Compatibility: Ensure that the version of Wechaty you're using is compatible with the Padlocal gateway. Sometimes, updates in either Wechaty or Padlocal can introduce compatibility issues that might affect the login process.

  3. Network and Account Checks: Make sure there are no network connectivity issues that could be preventing your bot from communicating with the Wechaty and Padlocal services. Additionally, verify that the WeChat account you're attempting to log in with is not restricted or too new, as these factors can also impact the ability to log in.

  4. Ensure Timely QR Code Scanning: The QR code generated for login must be scanned within a certain timeframe. If it's not scanned quickly enough, the login process will fail, and the bot might get stuck waiting for a successful login.

  5. Update Dependencies: Confirm that all your dependencies, including Wechaty and any related packages, are up to date. Outdated dependencies can lead to unexpected behavior and compatibility issues.

  6. Review Event Handlers: Take a closer look at your on_scan and on_login event handlers in your bot's code. These handlers play a critical role in managing the QR code scanning and the subsequent login process. Ensure they're implemented correctly and are capable of handling the events as expected.

If after following these steps, you're still facing issues, it might be beneficial to reach out to the Wechaty community or Padlocal support for more specific guidance. The Wechaty GitHub repository is also a valuable resource for updates and information that might help address your problem.

Details

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.

To continue the conversation, mention @dosu.

@chickenWing-ape
Copy link

padlocal网关一直循环输出 07:57:15 VERB StateSwitch on(pending) <- (false) 07:57:15 INFO [PuppetPadlocal] start login with type: QrLogin 07:57:30 VERB EventStreamManager grpcEmit(EVENT_TYPE_HEARTBEAT[1], {"data":"heartbeat@padlocal"}) 07:57:36 VERB StateSwitch off(pending) <- (false) 07:57:36 VERB StateSwitch off(true) <- (pending)

我的机器人启动后就一直在等待: 2024-05-10 15:56:04,504 - Wechaty - INFO - starting puppet ... 2024-05-10 15:56:04,504 - PuppetService - INFO - init puppet ... 2024-05-10 15:56:04,505 - PuppetService - INFO - starting the puppet ... 2024-05-10 15:56:04,589 - PuppetService - INFO - puppet has started ... 2024-05-10 15:56:04,589 - PuppetService - INFO - listening the event from the puppet ...

请问是什么原因?

我现在也是,之前还是好的,不断的循环,可以打印出状态,是 扫描,确认,然后就一直等待了,status又变为2。

@chickenWing-ape
Copy link

padlocal网关一直循环输出 07:57:15 VERB StateSwitch on(pending) <- (false) 07:57:15 INFO [PuppetPadlocal] 使用类型开始登录:QrLogin 07:57:30 VERB EventStreamManager grpcEmit(EVENT_TYPE_HEARTBEAT[1], {"data":"heartbeat@padlocal"}) 07:57:36 VERB StateSwitch 关闭(待处理)<-(假) 07:57:36 VERB StateSwitch 关闭(true)<-(待处理)

我的机器人启动后就一直在等待: 2024-05-10 15:56:04,504 - 微信 - INFO - 启动 puppet ... 2024-05-10 15:56:04,504 - PuppetService - INFO - init puppet ... 2024-05-10 15:56:04,505 - PuppetService - 信息 - 启动木偶... 2024-05-10 15:56:04,589 - PuppetService - 信息 - 木偶已启动 ... 2024-05-10 15:56 :04,589 - PuppetService - INFO - 从木偶监听事件......

请问是什么原因?

方便留个联系方式,讨论一下吗

Copy link

dosubot bot commented May 10, 2024

It appears that the continuous loop issue during the login process with the Padlocal gateway might be due to the service discovery mechanism not completing as expected. Implementing a retry mechanism in your code could help manage this by limiting the number of attempts to discover the service before handling it as an error or exiting the process. This approach ensures that your bot doesn't indefinitely wait for a successful connection.

Here's a basic structure for adding a retry mechanism to your code. While this example is more generic, you should adapt it to fit the specific logic and language you're working with:

retry_count = 0
max_retries = 5  # Set your preferred maximum number of retries

while retry_count < max_retries:
    try:
        # Attempt to connect or discover the service here
        # If successful, break out of the loop
        break
    except Exception as e:
        # Log the exception or handle it as needed
        print(f"Attempt {retry_count + 1} failed: {str(e)}")
        retry_count += 1
        if retry_count >= max_retries:
            print("Max retries reached. Handling failure...")
            # Implement your failure handling logic here
            break

Ensure that your environment variables, especially those related to the Padlocal gateway, are correctly configured. Mistakes in these settings can lead to login issues.

If after implementing these suggestions you're still facing difficulties, it might be beneficial to closely review your event handlers for scan, login, and message events. Proper handling of these events is crucial for the bot's operation, including the login process.

Should the problem persist, reaching out to the Wechaty community or Padlocal support for more targeted assistance could provide further insights into resolving the issue.

Details

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.

To continue the conversation, mention @dosu.

@tieguowei
Copy link
Author

已解决,代理关了就好了@chickenWing-ape

@chickenWing-ape
Copy link

已解决,代理关了就好了@chickenWing-ape

代理关了是指?网络上的代理吗?

@chickenWing-ape
Copy link

@chickenWing-ape tw161729810 我的v

用户不存在呀呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants