Table of Contents
php的swoole扩展中onclose和onconnect接口不被调用的问题,swooleonclose
Home php教程 php手册 php的swoole扩展中onclose和onconnect接口不被调用的问题,swooleonclose

php的swoole扩展中onclose和onconnect接口不被调用的问题,swooleonclose

Jun 13, 2016 am 08:47 AM
php swoole and Expand interface use of tune question

php的swoole扩展中onclose和onconnect接口不被调用的问题,swooleonclose

  在用swoole扩展写在线聊天例子的时候遇到一个问题,查了不少资料,现在记录于此。

  通过看swoole_server的接口文档,回调注册接口on中倒是有明确的注释:

* swoole_server->on & swoole_http_server->on are the same except swoole_http_server :
     * - not accepting onConnect/onReceive callback accept events onRequest
Copy after login

 

swoole_http_server和swoole_server大体是相同的,但是swoole_http_server中是不调用connect和receive接口的,相对应调用request接口。

  在聊天的小例子中用的是swoole_websocket_server,通过测试在swoole_websocket_server中receive接口也是没有被调用的,但是作为长连接服务,worker中

close和connect中的回调还是有必要的。比如上线广播通知,下线广播通知,都是需要回调这两个对应的接口才能很好的实现。所以官方肯定是支持回调的。

  最后找到问题是通过一份swoole版本更新公告。

  swoole-1.7.16 版本已发布,BUG 修复版本:

增加swoole_server->tick和swoole_timer_tick函数
增加http服务器对gzip压缩的支持
增加swoole_table->incr/decr原子自增/自减方法
增加open_eof_split配置,使用EOF检测可以支持自动分包
增加server统计项request_count和worker_request_count
增加server的连接迭代器,可以使用foreach遍历服务器的所有连接
增加http服务器请求的query_string
增加http服务器multipart-form和上传文件的支持
修复onReceive数据合并失效的BUG
修复swoole_server->addtimer与tick定时器冲突的BUG
修复低版本Linux下Accept未设置阻塞的问题
修复Accept失败返回Too Many Connection重复打印日志的问题
修复task_max_request参数失效的问题
修复swoole_client的waitall参数失效问题
修复swoole_table发生死循环的BUG
WebSocket服务器onOpen回调函数第2个参数由$fd调整为$request对象
Http服务器允许发送空body的response
禁用swoole_websocket_server->send方法
BASE模式支持向任意FD发送数据
设置dispatch_mode = 1, 3 后关闭onClose/onConnect事件回调
允许Worker进程内设置非系统保留信号
移除swoole底层对对象资源属性的依赖,直接读取指针,提升性能
解决心跳线程无法强制杀掉遗留连接的问题
优化dispatch_mode=3模式,提升任务分配的效率

     是worker分配模式的问题。在抢占模式和轮询模式,这两个回调接口不在被调用。固定模式,每个客户端的数据包都会由固定的worker进程处理,这样就可以在worker进程中存放一些属于这个客户端的私有信息,缓存一部分读写频繁的数据,就和erlang中的进程词典类似的操作。这样客户端在下线时,要做一些清理操作。上线初始化操作。所以这个模式是很有意义,也是很有必要的。固定模式适合处理每个客户端逻辑相对均匀的情况。

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles