PHP swoole extension OnClose and OnConnect interfaces are not called issues

Source: Internet
Author: User
In the Swoole extended to write the example of online chat encountered a problem, looked up a lot of information, now recorded here.

By looking at the interface document of the Swoole_server, there is a clear comment in the callback registration interface on:

* Swoole_server->on & Swoole_http_server->on is the same except Swoole_http_server:     *-not accepting OnCo Nnect/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 should be called.

In the small chat example is swoole_websocket_server, through the test in the Swoole_websocket_server receive interface is also not called, but as a long connection service, the worker

Callbacks in close and connect are still necessary. For example, on-line broadcast notification, offline broadcast notification, are required to callback the two corresponding interfaces to be very good implementation. So the authorities are definitely backing the callback.

The last problem was to update the announcement with a swoole version.

swoole-1.7.16 version released, BUG fix version:

Add Swoole_server->tick and Swoole_timer_tick functions
to increase the HTTP server's support for gzip compression
increase SWOOLE_TABLE->INCR/DECR Atomic self-increment/ The auto-Subtract method
increases the Open_eof_split configuration by using EOF detection to support automatic subcontracting
to increase the server statistics entries Request_count and Worker_request_count
Increase the server's connection iterator. You can use foreach to traverse all connections to the server
increase the query_string of HTTP server requests
to add support for HTTP server multipart-form and upload files
fix bug that onreceive data merge fails
Fix Swoole_server->addtimer bug with tick timer
fix a problem with the lower version of Linux under accept not set blocking
Fix accept failed to return too many Connection duplicate print log problem
Fix task_max_request parameter invalidation
fix swoole_client waitall parameter invalidation problem
Fix swoole_table a bug that has a dead loop
WebSocket Server OnOpen callback function 2nd parameter adjusted by $FD to $request Object
HTTP server allows sending of empty body response
Disable swoole_websocket_server- >send Method
Base mode supports sending data to any FD
setting Dispatch_mode = 1, 3 closing Onclose/onconnect event callback
Allow worker processes to set non-system reserved signals
Remove Swoole underlying dependency on object resource properties, directly read pointers, improve performance
Resolves a problem in which the heartbeat thread cannot force a legacy connection to be killed
Optimize dispatch_mode=3 mode, Increase the efficiency of task assignments

is a problem with the worker assignment pattern. In preemption mode and polling mode, these two callback interfaces are not called. In fixed mode, each client's packet is processed by a fixed worker process, so that it can store some private information belonging to the client in the worker process, and cache part of the data that reads and writes frequently, similar to the process dictionary in Erlang. This allows the client to do some cleanup operations when it is offline. On-line initialization operation. So this pattern is very meaningful and necessary. Fixed mode is suitable for handling the relative uniformity of each client's logic.

The above describes the PHP swoole extension onclose and OnConnect interface is not called, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.