问题标签 [curl-multi]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - PHP cURL 多句柄更改选项
更改一些选项并删除其他资源我不能使用相同的多句柄:
我明白:
我想看看:
传输后,您只需在句柄中设置新选项并进行另一次传输。如果可以的话,这将使 libcurl 重新使用相同的连接。
可以帮我?
谢谢
php - Handling multiple outbound API calls in a PHP web application
I'm working on a PHP (Zend Framework) web application that, for each user request, makes multiple calls to external APIs (SOAP and/or REST over HTTP).
At the moment, the API calls are sequential:
- Call API A, wait around 1 second for results
- Call API B, wait around 1 second for results
- Send page back to the user
In this instance there is no dependency or relation between APIs A and B; I simply want to return the page with all the information as quickly as possible.
At the moment I'm thinking of either:
- curl_multi_exec() - http://php.net/manual/en/function.curl-multi-exec.php
- ZeroMQ - http://www.zeromq.org/
curl_multi_exec() would bind my client code for APIs A and B more tightly than I'd like.
ZeroMQ seems more complex to implement, and I'm not sure how I'd manage the worker processes and sockets.
Has anyone successfully implemented this behaviour in a PHP/Apache application without too much fuss?
php - curl_exec:如何取消长时间运行的 HTTP 请求?
我正在使用 PHP 的 curl_exec() 向一个运行时间很长的 API 发出请求。但我实际上并不需要知道结果,我只需要启动过程。
这个过程是成功还是失败对我来说并不重要。所以我想在我提出请求后立即断开连接。
如何删除 curl_exec 连接?我不想等待 30 - 60 秒的响应:
我相信解决方案可能会涉及 curl_multi?
php - PHP 多卷曲或多线程
我正在构建一个 cron 作业,它执行以下操作:
1. 从 DB
2 中获取记录。对于每条记录,都会向 API 发出一个 curl 请求。(有些请求很快,有些正在上传大图像或视频)。
3、如果一个请求不成功,新建一个参数稍有不同的请求(还是根据记录),重新发送。这可能会发生多次。
4. 请求成功后,执行一些数据库选择/插入(基于导致发送此请求的原始记录)。
发送请求应该并行发生,因为有些需要几分钟(大量上传),有些非常快。
这样做最合适 - 拥有一个从数据库获取记录并为每个记录创建一个进程来处理调用 API 和解析响应的主脚本?或者使用 curl_multi 从同一个脚本同时发送多个请求并在返回时解析每个请求?
如果使用多个进程,那么最好的方法是什么 - PCNTRL、popen 等?
如果使用 curl_multi 我怎么知道哪个数据库记录对应哪个返回请求?
编辑:如果使用 curl multi 我可能会采用这种技术:http
://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/
这样它就不会等待在我开始处理响应之前完成的所有请求。
谢谢!
php - cURL 在链中使用多个代理
是否可以使用 cURL 在单个请求中链接多个代理?
例如:起始 cURL -> proxy1 -> proxy2 -> 目标地址
这可以使用 cURL 来实现吗?
php - 当超时 > 2 时,请求总是*至少需要 1 秒
好吧,这真的很奇怪。当我向本地主机发出请求时(大约需要 1-2 毫秒),curl 需要更长的时间。它似乎取决于超时(ConnectionTimeout / normaltimeout 的最低值)。
所有请求都成功
- 当 Timeout_Ms = 5 时,curl 恢复的时间约为 1 Ms。
- 当 Timeout_Ms = 50 时,curl 恢复的时间约为 4 Ms。
- 当 Timeout_Ms = 500 时,卷曲恢复的时间约为 250 毫秒。
- 当 Timeout_Ms = 1000 时,curl 恢复的时间约为 500 Ms。
- 当 Timeout_Ms = 1500 时,curl 恢复的时间约为 750 Ms。
- 当 Timeout_Ms > 2000 时,curl 恢复的时间约为 1000 Ms。
因此,当将超时设置为高时,请求总是需要 1 秒。使用 curl_multi 时,时间也增加了 1 秒,但我做了多少请求并不重要。
我有两个要求:
- 一个需要 5 秒 -> 6 秒后完成
- 第二个需要 10 秒 -> 11 秒后完成
php - PHP curl multi在密码站点上
我目前正在使用以下(旧)代码登录网站...
然后我用...
...对于每个页面请求。我的问题是,我怎样才能将其转换为使用 curl_multi_exec 来更快地进行数百次查找?我找不到 curl_multi WITH 登录的任何示例。我只是用 curl_multi_exec 替换所有 curl_execs 吗?此外,如果您发现任何其他明显的错误,当然欢迎发表评论。
需要明确的是,我想使用单个用户/密码登录,然后将这些凭据重用于多个页面请求。
php - 使用 PHP curl_multi 的单个响应时间
使用 curl_multi 可以记录每个进程的响应时间吗?这是我目前正在使用的代码我只是不确定如何记录每个进程的响应时间。谢谢你的帮助!
php - curl_errno 返回 0 而不是 6
输出
在相同的情况下,尽管 curl_error 返回错误消息,但 multi curl 使用 curl_errno 函数返回 0。