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

推荐订阅源

P
Privacy International News Feed
WordPress大学
WordPress大学
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
Microsoft Security Blog
Microsoft Security Blog
G
GRAHAM CLULEY
N
News | PayPal Newsroom
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
美团技术团队
J
Java Code Geeks
I
Intezer
The Cloudflare Blog
SecWiki News
SecWiki News
S
Secure Thoughts
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
D
DataBreaches.Net
S
Security Affairs
Help Net Security
Help Net Security
S
Securelist
F
Full Disclosure
C
Check Point Blog
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园_首页
G
Google Developers Blog
Google Online Security Blog
Google Online Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hacker News: Front Page
L
LINUX DO - 热门话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog

PHP

新版六国语言小额 JieDai 系统源码 - V2EX 免费虚拟主机空间安装的一个 PHP 文件论坛 - V2EX 有没有什么好用的免费开源 CRM 系统 - V2EX 2026 年 PHP 路在何方 - V2EX 2026 年,学 laravel 有没有前途: - V2EX 有没有这样的 PHP 框架 - V2EX PHP 是不是快死了 - V2EX php74-fpm 加 nginx, PHP 文件只要不是 root /var/www/html 就提示 No input file specified.求大佬看看 - V2EX PHP framewok 框架推荐 - V2EX 基于 yii2 框架开发的后台管理软件,免费 - V2EX 「一键部署你的专属服务器」——WNMP 一键包,让 Web 环境搭建回归简单 - V2EX 完蛋了,为什么我感觉 PHP 的语法这么优雅呢 - V2EX 未来属于 PHP - V2EX 记一次微信 access_token invalid credential, access_token is invalid or not latest - V2EX 重造 PHP -HTTP 性能检测,新增 List<int>、HashMap<K, V> - V2EX 求助: PHP 错误,请高手帮我改写下面的 PHP 代码 - V2EX 为什么现在 WEB3、区块链、钱包之类开始用 PHP 了 - V2EX PHP 8.5 加入了 pipe 语法 - V2EX 推荐一个优雅的 PHP http 请求工具,仿照了 py 的 requests - V2EX 大家好,我又來了,新作品 https://www.freetalkhub.com, PHP 开发 - V2EX laravel 和 thinkphp 选择哪个? - V2EX 202505 最新调研: PHP Opcode 加密混淆哪家强? - V2EX 有做过基于 webrtc 技术的多人视频会议系统的吗 - V2EX 2025 年 PHP 路在何方 - V2EX 求助 CodeIgniter 输出的 html 格式很乱,缩进乱七八糟的。。。 - V2EX 有个关于 PHP 的小疑惑 - V2EX 目前 PHP 中比较好用的工作流引擎有哪些? - V2EX 有老哥熟悉 OpenCart 的吗? - V2EX 开源 PHP Composer 私有 package 管理平台 - V2EX 推荐个好用的集成环境 - V2EX phpinfo(); logo 变成了绿色的大象 - V2EX PHP 项目有类似前端 monorepo 的概念吗? 想用 PHP 做微服务开发,有偿求指导 - V2EX PHP 语言已经过气了吗 - V2EX 国内 PHP 卷王是鸟哥 mysql update 更新失败的原因。 - V2EX PHP 程序员是往运维还是前端发展作为拓展呢 - V2EX 求大佬解决一下一个问题 - V2EX [2024-11-21] PHP 8.4 Released! - V2EX 如何获得抖音视频播放量?各位大牛支支招~ 如何优雅地切换 composer 镜像 - V2EX 与银行对接 sm4 国密算法 - V2EX Laravel 二手项目,语言切换问题,求解 - V2EX 两道 PHP 题目,都是求 flag 值 帮忙推荐一个开源论坛源码? Laravel 完成了 A 轮融资🎉 - V2EX PHP 虽然没落了,但是 PHP 的东西是真的好用 - V2EX 世界上最好的 serverless 平台! - V2EX imgur 是怎么做到一个链接新窗口打开 302,但是还能作为图片显示的? - V2EX PHP 编译器 BPC 编译 ThinkPHP8 + PHPUnit 测试 的视频来了 - V2EX
workman 与阿里云实时语音通信的问题。 - V2EX
awanganddong · 2025-04-24 · via PHP

这是一个创建于 417 天前的主题,其中的信息可能已经有所发展或是发生改变。

    /**
     * 项目 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 不存在数据。

awanganddong

1

awanganddong      2025 年 4 月 24 日

我是一套客户端和服务端的长连接,一套服务端与阿里云的长连接(启动在 onConnect 中启动)

断线重连后,通过 channel 给阿里云 aws 发送消息,但是没响应。不知道为什么出现这种问题。

lyxxxh2

2

lyxxxh2      2025 年 4 月 24 日

我猜测的可能:
1. self::aliWs->send 没发送成功
- 打印只能证明调用了

2. self::$aliWs 跟 $ws 不是同个实例。
- 看你代码,肯定是同个实例。 但是你实际代码肯定不这样。

awanganddong

4

awanganddong      2025 年 4 月 24 日

我是没外界用户没建立一个长连接,就起一个阿里的 ws 服务。
class Events
{

public static $sendTaskKey = "send-task_relation::";

public static $sendAliyunChan;

public static $sendWsChan;

protected static $aliWs = null;
}
在这里定义

awanganddong

5

awanganddong      2025 年 4 月 24 日

self::$aliWsArr[$client_id] = $ws;
我应该这样存数据

kivmi

6

kivmi      2025 年 4 月 27 日

链接 reconnect 能成功吗?超时就断开了,虽然你这边还持有这个链接对象,但是已经失活了吧!

awanganddong

7

awanganddong      2025 年 4 月 28 日

现在 reconnect 没有使用,超时断了就断了。
失活这种情况。我测试 下。现在给阿里 ars 发关闭消息,确实不生效。