惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
Y
Y Combinator Blog
D
DataBreaches.Net
I
InfoQ
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
G
Google Developers Blog
博客园_首页
博客园 - 司徒正美
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
D
Docker
量子位

PHP

PHP 是不已经没有公司实际在招了 - V2EX 刚哥开发新的编程语言 TypePHP,周三放到 Github , 3 天 star 就快 900 个了,https://github.com/swoole/typephp,大家用 AI 体验下编程 - V2EX 极致精简,已经优化为仅 100 多 KB!单文件 PHP 论坛! - V2EX 新版六国语言小额 JieDai 系统源码 - V2EX 免费虚拟主机空间安装的一个 PHP 文件论坛 有没有什么好用的免费开源 CRM 系统 2026 年 PHP 路在何方 2026 年,学 laravel 有没有前途: 有没有这样的 PHP 框架 PHP 是不是快死了 php74-fpm 加 nginx, PHP 文件只要不是 root /var/www/html 就提示 No input file specified.求大佬看看 PHP framewok 框架推荐 基于 yii2 框架开发的后台管理软件,免费 「一键部署你的专属服务器」——WNMP 一键包,让 Web 环境搭建回归简单 完蛋了,为什么我感觉 PHP 的语法这么优雅呢 未来属于 PHP 记一次微信 access_token invalid credential, access_token is invalid or not latest 重造 PHP -HTTP 性能检测,新增 List<int>、HashMap<K, V> 求助: PHP 错误,请高手帮我改写下面的 PHP 代码 为什么现在 WEB3、区块链、钱包之类开始用 PHP 了 PHP 8.5 加入了 pipe 语法 推荐一个优雅的 PHP http 请求工具,仿照了 py 的 requests 大家好,我又來了,新作品 https://www.freetalkhub.com, PHP 开发 laravel 和 thinkphp 选择哪个? 202505 最新调研: PHP Opcode 加密混淆哪家强? 有做过基于 webrtc 技术的多人视频会议系统的吗 2025 年 PHP 路在何方 求助 CodeIgniter 输出的 html 格式很乱,缩进乱七八糟的。。。 有个关于 PHP 的小疑惑 目前 PHP 中比较好用的工作流引擎有哪些?
workman 与阿里云实时语音通信的问题。
awanganddong · 2025-04-24 · via PHP
    /**
     * 项目 socket 连接时触发(一次)
     * 当客户端与 Workerman 建立连接时(TCP 三次握手完成后)触发的回调函数
     */
    public static function onConnect($client_id)
    {

        // 定义连接函数
        $connectWs = function () {

            $ws            = new AsyncTcpConnection('ws://dashscope.aliyuncs.com/api-ws/v1/inference');
            $ws->headers   = [
                "Authorization" => "Bearer " . getenv("DASHSCOPE_API_KEY"),
            ];
            $ws->transport = "ssl";

            // 连接成功回调
            $ws->onConnect = function ($ws) {
                self::$aliWs = $ws;
                echo "connected success:" . $ws->id . "\n";
            };

            // 当收到消息时
            $ws->onMessage = function ($ws, $data) {
                var_dump("ali 返回消息", $data);
                $msg     = json_decode($data, true);
                $channel = self::$sendWsChan;
                Coroutine::create(
                    function () use ($channel, $msg) {
                        $channel->push($msg);
                    },
                );
            };

            // 连接关闭时进行重连
            $ws->onClose = function ($ws) {
                echo "连接关闭,尝试重新连接...\n";
                self::$aliWs = null;
                $ws->reConnect(1);
            };
            $ws->onError = function ($ws) {
                echo "错误输出" . $ws->error;
            };
            $ws->connect();
        };
        
        		//定时器触发
                  if (self::$aliWs) {
                                var_dump("发送事件");
                                self::$aliWs->send(json_encode($data));
                            }

初次建立长连接可以发送成功,但是如果阿里云长连接断线重连几次后,发送事件,在 onMessage 里边没有响应。不明白为什么出现这种情况。var_dump("发送事件"); 可以打印数据。但是 onMessage 不存在数据。