


The problem that the onclose and onconnect interfaces are not called in the swoole extension of PHP, swooleonclose_PHP tutorial
The problem that the onclose and onconnect interfaces are not called in the swoole extension of PHP, swooleonclose
I encountered a problem when using the swoole extension to write an online chat example, and I checked a lot The information is now recorded here.
By looking at the interface document of swoole_server, there is a clear comment in the callback registration interface on:
* swoole_server->on & swoole_http_server->on are the same except swoole_http_server : * - not accepting onConnect/onReceive callback accept events onRequest
swoole_http_server and swoole_server are roughly the same, but the connect and receive interfaces are not called in swoole_http_server, and the request interface is called accordingly.
In the small example of chatting, swoole_websocket_server is used. Through testing, the receive interface in swoole_websocket_server is not called, but as a long connection service, in the worker
The callbacks in close and connect are still necessary. For example, online broadcast notifications and offline broadcast notifications require callbacks to these two corresponding interfaces to implement them well. So the official definitely supports the callback.
The problem was finally found through a swoole version update announcement.
swoole-1.7.16 version has been released, BUG fixed version:
Add swoole_server->tick and swoole_timer_tick functions
Add http server support for gzip compression
Add swoole_table->incr/decr atomic increment/decrement method
Add open_eof_split configuration, use EOF Detection can support automatic subcontracting
Add server statistical items request_count and worker_request_count
Add server connection iterator, you can use foreach to traverse all connections of the server
Add http server request query_string
Add http server multipart -Support for form and uploaded files
Fix the BUG of onReceive data merging failure
Fix the BUG of conflict between swoole_server->addtimer and tick timer
Fix the problem of Accept not setting blocking under low version Linux
Fix the problem of Repeated Log Printing when Accept fails and returns Too Many Connection
Fix the problem of invalid task_max_request parameter
Fix the problem of invalid waitall parameter of swoole_client
Fix the bug of infinite loop in swoole_table
WebSocket server onOpen callback function No. The two parameters are adjusted from $fd to $request object
Http server allows sending empty body response
Disable swoole_websocket_server->send method
BASE mode supports sending data to any FD
Set dispatch_mode = 1, 3 and then close the onClose/onConnect event callback
Allow setting of non-system reserved signals in the Worker process
Remove the underlying dependence of swoole on object resource attributes and read them directly Pointers, improve performance
Solve the problem that the heartbeat thread cannot forcefully kill legacy connections
Optimize the dispatch_mode=3 mode to improve the efficiency of task distribution
It is a problem of worker allocation mode. In preemption mode and polling mode, these two callback interfaces are no longer called. In fixed mode, each client's data packet will be processed by a fixed worker process, so that some private information belonging to this client can be stored in the worker process, and some frequently read and written data can be cached, which is similar to the process dictionary in Erlang. operate. In this way, the client needs to do some cleaning operations when it goes offline. Online initialization operation. So this model is very meaningful and necessary. Fixed mode is suitable for handling situations where each client's logic is relatively uniform.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

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

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

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

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

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

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

This chapter deals with the information about the authentication process available in CakePHP.
