Swoole | 【Swoole 从入门到实战】学习笔记,从零开始学 Swoole,包括 Swoole Task,Swoole | HTTP library
kandi X-RAY | Swoole Summary
kandi X-RAY | Swoole Summary
【Swoole 从入门到实战】学习笔记,从零开始学 Swoole,包括 Swoole Task,Swoole WebSocket,Swoole HTTP 服务,Swoole RPC 服务,Swoole MySQL 连接池,Swoole Redis 连接池,Swoole 压测等,其中 7 个源码分享,11 篇总结文章分享。
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Start swoole server
- run task
- On request
- Returns a usable database connection
- run WSD task
- Get list of orders
- init redis
- Get home page
- get mysql connection
- Send demo .
Swoole Key Features
Swoole Examples and Code Snippets
Community Discussions
Trending Discussions on Swoole
QUESTION
I am getting the following errors after doing docker-compose up -d
:
exit code: 100 Service 'laravel.test' failed to build : Build failed
I am running this from a Bash terminal in Windows 10. It's for a Laravel PHP application.
Here is my docker-compose.yml
file:
ANSWER
Answered 2022-Mar-21 at 17:11Turns out I had to update the Laravel Sail version by doing a composer update
outside of the docker container. I have WAMP installed locally so I was able to run the composer update. Just ensure your PHP CLI version matches the one required in the Docker container.
QUESTION
pcntl_alarm(int $seconds)
only has a resolution of seconds. Is there a way in PHP to signal a SIGALRM with a delay of, say, milliseconds? Maybe a posix_kill()
with a delay argument?
PS.: I'm aware of Swoole\Process::alarm()
from the PECL extension Swoole, but I'm looking for a more bare-bones PHP solution.
ANSWER
Answered 2022-Mar-20 at 16:37I found one way to do it, but it is a bit convoluted:
QUESTION
I'm having issues getting Laravel Sail to work on new laravel 8
project, I'm on Ubuntu 20.04 LTS
, i followed the instructions as explained on Laravel Sails Documentation
What i did so far was :
First i created a new Laravel Project :
...ANSWER
Answered 2021-Dec-05 at 14:44Basically this error means there is no connectivity between the container and the internet but i wasn't able to figure out why this happened.
Thanks to Rwd who did mention this Github Issue in the comment section i noticed that am using an old version of docker
, i was running Ubuntu 16.04 .. later i upgraded to 20.04, during the upgrade the docker repository was disabled so i ended up not upgrading docker for quiet a time.
So what i did was simply reinstalling docker
:
I removed the old versions
QUESTION
I'm very new to the docker technology.
What i'm trying to do, is install the PHP extensions sqlsrv and pdo_sqlsrv from PECL repo. Accordingly to this tutorial:
Before i get data from this repo i install the following php additions:
...ANSWER
Answered 2021-Nov-19 at 08:36The easiest way is using this repo
It's as easy as
QUESTION
I'm migrating from Laravel 8 to Laravel 8 + Octane / Swoole. All works fine, but php://input
always are empty. Also, I check $_POST and $_SERVER values.
file_get_contents('php://input')
is used by AWS SNS Message Validator.
Any alterantive to read php://input
?
ANSWER
Answered 2021-Jul-29 at 22:24php://input
are not available on Swoole. Always are the same running process.
QUESTION
I installed docker and downloaded an ubuntu distro to run with laravel sail,planing to use swoole php,and made it default,also made wsl version to 2
with docker-compose.yml ready from laravel sail docker-compose.yml:
but every time I try to run the sail up cmd,it gives me this error " Unsupported operating system [MINGW64_NT-10.0]. Laravel Sail supports macOS, Linux, and Windows (WSL2)."
any ideas how to fix this ?
...ANSWER
Answered 2021-Feb-28 at 23:53You need to run the sail up command from inside your WSL2 Ubuntu Image not directly from your terminal. Once you do that it should work ok
QUESTION
When Swoole is on heavy load and heavy requests I kept getting this Log:
[2021-01-24 16:07:22 *33833.2] NOTICE finish (ERRNO 1005): session#21022 does not exists
[2021-01-24 16:07:22 *33833.2] NOTICE finish (ERRNO 1005): session#21022 does not exists
[2021-01-24 16:07:22 *33833.2] NOTICE finish (ERRNO 1005): session#21022 does not exists
[2021-01-24 16:07:22 *33833.2] NOTICE finish (ERRNO 1005): session#21022 does not exists
[2021-01-24 16:07:39 *33835.4] NOTICE finish (ERRNO 1005): session#21025 does not exists
[2021-01-24 16:07:39 *33835.4] NOTICE finish (ERRNO 1005): session#21025 does not exists
[2021-01-24 16:07:39 *33835.4] NOTICE end (ERRNO 1005): session[21025] is closed
Or
[2021-01-23 14:07:22 *5300.3] NOTICE php_swoole_http_onReceive (ERRNO 1005): session[10002] is closed
[2021-01-23 14:07:22 *5300.3] NOTICE php_swoole_http_onReceive (ERRNO 1005): session[10042] is closed
[2021-01-23 14:08:21 *5326.29] NOTICE php_swoole_http_onReceive (ERRNO 1005): session[10508] is closed
[2021-01-23 14:18:15 *5333.36] NOTICE finish (ERRNO 1005): session#12755 does not exists
[2021-01-23 14:18:15 *5333.36] NOTICE end (ERRNO 1005): session[12755] is closed
In example I send total 500k requests with 1k concurrent requests, it logs this errors and hangs !
And suddenly it hangs !
My server is Centos 7, 8 gigabytes of RAM and 4 cores of CPU.
Swoole is running with 40 workers, + 30 Master-Worker and 8 Reactor.
Even in production this happens too.
Can some one help me or explain me why this happens and maybe how can I solve it?
Thanks.
ANSWER
Answered 2021-Jan-24 at 19:12Ok I have found where is the problem. Actually it's not a bug in Swoole or my application. It's a notice log that can get disabled with log_level property of Swoole server configuration. This happens when a Client closes swoole tab or browser (Closes client connection), so it gets disconnected so Swoole cannot retrieve users session and logs this notice. Also if you are using bench marking tools like Apache ab or WRK, If a problem occurs, These testers will terminate all other requests and stop whole testing. So sessions get closed and logs written again.
QUESTION
I have installed php/swoole on my server and configured it using Laravel swoole
Now The problem is everything works fine until total requests per second number increase more than 1000 requests.
Swoole will log an error and not responding to user !
I have set Operating system ulimit number to 50000
But still get same error ! Searching all over internet and find nothing !
Os Centos 7
Server is good enough to handle more than 1k requests per second
If you have any experience about this please share it with me
Note:
When swoole starts, it logs this error too:
set_max_connection: max_connection is exceed the maximum value, it's reset to 1024
ANSWER
Answered 2021-Jan-19 at 14:48Ok I have figured it out.
lets first say that how I ran PHP-Swoole process: .
I have made a systemd service in centos in order to launch swoole process all the time in any situation..
So the ULimit command sets ulimit for current shell that you are in it. Not the systemd shell that is running swoole starter process..
For that you need to add LimitNOFILE=100000
option under systemd [Service]
section block.
And with a restart everything works fine.
QUESTION
I'm trying to understand how are we supposed to manage client in Swoole Websocket Server.
I've MyServer who extends from Swoole\WebSocket\Server, I store in a property the client list, but it seems every single client can only see his own list (with only him in it). So if the client 1 send a message who have to be resent to the client 2, the only I've found is to use the getClientList method and send the message to all clients.
But I want also to "bind" clients between themselves ... Like 1 with 2 only, 3 with 4 a,nd 5 etc.
I use APCu (forced to CLI mode) to communicate client list to all my client, but it seems I've some multi acces problems now.
Isnt a "native" way in Swoole Websocket Server to store information on my client, information who could by read from any client?
...ANSWER
Answered 2020-Jul-12 at 07:51After some more research, I found that Swoole provide a nice build-in class to manage session interaction : Swoole/Table
It's a fast "SQL like" memory management system that allow you to easily communicate between sessions, specifically usefull for websockets session!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Swoole
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page