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

[BUG]开发者,代码中指定配置文件的路径不生效 #230

Closed
phpnbw opened this issue Jan 5, 2025 · 19 comments
Closed

[BUG]开发者,代码中指定配置文件的路径不生效 #230

phpnbw opened this issue Jan 5, 2025 · 19 comments
Labels
故障(bug) 代码问题导致的错误(Bugs caused by code problems)

Comments

@phpnbw
Copy link

phpnbw commented Jan 5, 2025

查看了开发文档:https://f2.wiki/guide/what-is-f2
安照要求定义,发现并没有生效

我在我的配置文件中定义了 max_retries: 3,但是实际不生效,还是默认的5次
image
image

我的代码打印日志:
image

我的部分代码如下:

image

@phpnbw phpnbw added the 故障(bug) 代码问题导致的错误(Bugs caused by code problems) label Jan 5, 2025
Copy link

dosubot bot commented Jan 5, 2025

Hello @phpnbw! I'm here to help you with any bugs, questions, or contributions you might have. Let's work together to resolve this issue!

The issue you're experiencing with the max_retries parameter not being applied as expected might be due to how the configuration is being loaded and applied in the f2 library. Here are a few things to check and consider:

  1. Configuration File Path: Ensure that the app.yaml file is correctly set as the configuration file path. Your code seems to modify the APP_CONFIG_FILE_PATH to point to your app.yaml, which is correct. Verify that the path is correct and that the file is being read properly by checking the logs for any errors related to file reading or parsing.

  2. Configuration Loading: The ConfigManager class is responsible for loading configurations. Make sure that the max_retries parameter is being correctly loaded from the configuration file. You can add logging to confirm that the configuration is being loaded with the expected values.

  3. Parameter Application: Check where and how the max_retries parameter is used in the code. If the parameter is not being applied correctly, it might default to a hardcoded value elsewhere in the code. Unfortunately, I couldn't find specific information on how max_retries is handled in the f2 library, so you might need to review the relevant parts of the codebase where this parameter is used.

  4. Error Handling: The log message about the empty response content and proxy failure might indicate network issues or misconfiguration. Ensure that your network settings, including proxies, are correctly configured.

If these steps do not resolve the issue, consider reviewing the relevant parts of the f2 codebase where configuration parameters are applied, especially focusing on how max_retries is used.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

我怀疑cookie也是没生效的,整个配置文件可能就没加载成功,使用的还是默认的配置。
还是说 是我的代码有问题?

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Jan 5, 2025

#154 (comment)
这里有代码片段,我还没在文档中特意指出路径的问题,因为保持新版的标准是需要将配置文件放在conf文件夹中。

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

#154 (comment) 这里有代码片段,我还没在文档中特意指出路径的问题,因为保持新版的标准是需要将配置文件放在conf文件夹中。

新建了conf文件,代码也打印出重试次数了。但是为啥还是重试5次呢?
打印日志1:
image
打印日志2:
image

部分代码和项目结构:
image

@Johnserf-Seed
Copy link
Owner

#154 (comment) 这里有代码片段,我还没在文档中特意指出路径的问题,因为保持新版的标准是需要将配置文件放在conf文件夹中。

新建了conf文件,代码也打印出重试次数了。但是为啥还是重试5次呢? 打印日志1: image 打印日志2: image

部分代码和项目结构: image

原因出在构建DouyinHandler的kwargs参数里不包含max_retries,所以防止出错会使用默认值进行初始化。你应该再附加上这一块的日志或代码。
image
如果是开发者那么建议是把大多数参数全部放在默认的app.yaml中,这样子调用即可。

@Johnserf-Seed
Copy link
Owner

你可以将代码和配置脱敏后完整的附上,降低沟通的成本

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

你可以将代码和配置脱敏后完整的附上,降低沟通的成本

按照你说的方法可以了,说白了还需要使用运算符合并一下。为啥不在你的代码里面默认合并呢
image

@Johnserf-Seed
Copy link
Owner

你可以将代码和配置脱敏后完整的附上,降低沟通的成本

按照你说的方法可以了,说白了还需要使用运算符合并一下。为啥不在你的代码里面默认合并呢 image

因为kwargs的参数是灵活的,独立的,参数由开发者自己构建。命令行模式下是自动实现了这个操作的,提供了merge_config方法。

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Jan 5, 2025

参阅文档的代码片段,本质上是对kwargs这个参数的补充。配置文件只是辅助构建参数的作用。

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

参阅文档的代码片段,本质上是对kwargs这个参数的补充。配置文件只是辅助构建参数的作用。

了解。感谢大佬,项目不错!

再咨询个开发之外的问题:我使用了代理(代理确定可用)+cookie。本地可以调通接口,线上容器里就不行,这是啥原因?
接口就是上图里面出现的fetch_user_profile。报错就是:请求响应内容为空, 状态码: 200,

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Jan 5, 2025

参阅文档的代码片段,本质上是对kwargs这个参数的补充。配置文件只是辅助构建参数的作用。

了解。感谢大佬,项目不错!

再咨询个开发之外的问题:我使用了代理(代理确定可用)+cookie。本地可以调通接口,线上容器里就不行,这是啥原因? 接口就是上图里面出现的fetch_user_profile。报错就是:请求响应内容为空, 状态码: 200,

这个文档里有说,你可以自助排查一下cookie的问题,最稳定是使用登录的cookie。https://f2.wiki/faq#%E7%AC%AC-n-%E6%AC%A1%E8%AF%B7%E6%B1%82%E5%93%8D%E5%BA%94%E5%86%85%E5%AE%B9%E4%B8%BA%E7%A9%BA

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Jan 5, 2025

你可以将代码和配置脱敏后完整的附上,降低沟通的成本

按照你说的方法可以了,说白了还需要使用运算符合并一下。为啥不在你的代码里面默认合并呢 image

你现在用的是游客的ck,生产环境自然容易风控,这个ck的写法是用来获取直播流与弹幕的,因为他们不控

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

不是,我的配置文件里是有登录的cookie的,按照刚刚说的kwargs应该是合并使用的是配置文件里的cookie。感谢,定位到cookie的问题就行,我再看下怎么解决把。感谢回复!

@Johnserf-Seed
Copy link
Owner

不是,我的配置文件里是有登录的cookie的,按照刚刚说的kwargs应该是合并使用的是配置文件里的cookie。感谢,定位到cookie的问题就行,我再看下怎么解决把。感谢回复!

提一嘴,document.cookie获取的是无效的,参考faq里的获取方式,被控了可能需要去网页端过一下验证码或换代理重新登陆

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

不是,我的配置文件里是有登录的cookie的,按照刚刚说的kwargs应该是合并使用的是配置文件里的cookie。感谢,定位到cookie的问题就行,我再看下怎么解决把。感谢回复!

提一嘴,document.cookie获取的是无效的,参考faq里的获取方式,被控了可能需要去网页端过一下验证码或换代理重新登陆

按照文档里面的获取方式,cookie很长很长,这是正常的吗?

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Jan 5, 2025

不是,我的配置文件里是有登录的cookie的,按照刚刚说的kwargs应该是合并使用的是配置文件里的cookie。感谢,定位到cookie的问题就行,我再看下怎么解决把。感谢回复!

提一嘴,document.cookie获取的是无效的,参考faq里的获取方式,被控了可能需要去网页端过一下验证码或换代理重新登陆

按照文档里面的获取方式,cookie很长很长,这是正常的吗?

当然正常了,这才是完整的cookie,因为完整的ck不单单包括*.douyin.com这个域名里的

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

感觉我的生产环境ip被抖音风控了,我取消了代理(因为怀疑代理IP也有问题),结果fetch_user_profile还是本地可以调用,线上就不行。
还有:fetch_user_live_videos_by_room_id 这个方法不管本地还是线上都可以调用成功,

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Jan 5, 2025

感觉我的生产环境ip被抖音风控了,我取消了代理(因为怀疑代理IP也有问题),结果fetch_user_profile还是本地可以调用,线上就不行。 还有:fetch_user_live_videos_by_room_id 这个方法不管本地还是线上都可以调用成功,

那就是线上这个环境的问题了,ip被ban了,新环境可能控验证码了,因为用户信息这个接口是近期风控非常厉害的

@phpnbw
Copy link
Author

phpnbw commented Jan 5, 2025

好的,感谢大佬耐心回复!已点关注。这个issues可以结束了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
故障(bug) 代码问题导致的错误(Bugs caused by code problems)
Projects
None yet
Development

No branches or pull requests

2 participants