-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: go(): async-io must be used in PHP CLI mode #2221
Comments
It's also breaking my website I don't know why? I have now frequently error 500... (not in this script, on my whole server)... it's because extension=swoole.so in php.ini ... I'm sure it's because of that. |
Deleted extension=swoole.so and my server is working without error 500... -.- how to get this all working? with php-fpm and nginx as reverse proxy.... |
I hope you gonna help me because I see that your extension is perfect for what I need (couple thousands people online in real-time chat) |
I changed to PHP-CLI and still the same error as in first post.... |
it's impossible, make sure you just run |
But why I have to do this in console? I want to make it work in browser... |
Ok I ran it in console - it works... so how to get this work in browser? :) |
Swoole is not meant to work in browser, it is a cli based tool for long running tasks, and browser tasks are meant to be short lived tasks. I think you mentioned about chat app, the idea of swoole is that it can run as a script cli which your users connect to from the browsers. |
So how to get this work if my clients have my script in separate domain and dir (on my server) ?... I thought I can do this like that :/ |
I don't quite get what you mean, there is not enough information to answer your question. There are a few swoole projects using swoole to power chats, I think you can look into those to get the idea how things work. |
Have you some links? |
Google is your friend :), just search swoole chat you will find plenty such as: https://github.com/Rgss/swoole-chat-demo Some of them use rather old version of swoole though, but at least you can get the idea from there. |
Can only be run under the CLI model. |
P.S. If I have for example 100 clients - they have 100 scripts with chat... so I wanted to get this work by websockets because php + ajax is shit in performance for my server :P and I thought I can run swoole in php in browser :D |
Honestly I think you lack the basic understanding of how Chat programs work, so it would be best for you to start from there first. Also PHP never ever runs in browsers (at least till now), they always run on server, where CLI mode or not. Your clients from the server open websockets that connect to PHP to do the chat, that's it. You can even do that without swoole. Using swoole you are able to serve more users concurrently and that's the power of swoole. |
Ok maybe I get it... but tell me now why my website (without code from swoole like above) has error 500 every X clicks? If I have turned on extension=swoole.so in php.ini ... |
Since you can enable swoole for cli only, perhaps that's what you should, just enable swoole in cli extension and no where else. It's not meant to run in other modes. |
Ok I understand - thanks guys! :) |
yes |
I have another question - I think I know how this is working but.... what if I have this 100 separate chats on my server? I guess I should do something like create unique "channel" for every chat? but how? is this possible with swoole? |
You seriously need to start reading the documents :). But basically yes, something like this: As for php vs node, i dont think 100 users make any difference, we are talking about hundreds of thousands here. In the end it depends on the language you are more comfortable with. Read the documents, read the examples, and start from there. |
I didn't tell it's 100 users - it's 100 clients with 100 chats where for every chat can be unlimited people :D but nevermind, thanks for answers :) I now get it... finally :D |
I have error
Fatal error: go(): async-io must be used in PHP CLI mode
What did you do? If possible, provide a simple script for reproducing the error.
Swoole\Runtime::enableCoroutine(); $s = microtime(true); for ($c = 50; $c--;) { go(function () { $mysqli = new Mysqli('127.0.0.1', 'xxx', 'xxx', 'xxx'); $statement = $mysqli->query('SELECT * FROM (SELECT * FROM
shoutboxORDER BY
sid) AS
shoutboxORDER BY
shoutbox.
sidASC'); $i = 0; while ($test = $mysqli->fetch_array($statement)) { echo $i . ' - uid: ' . $test['uid'] . '<br>'; $i++; } }); } Swoole\Event::wait(); echo 'use ' . (microtime(true) - $s) . ' s';
What did you expect to see?
Just counting $i and see how it's performance on my server with swoole
Fatal error: go(): async-io must be used in PHP CLI mode
What version of Swoole are you using (show your
php --ri swoole
)?swoole
swoole support => enabled
Version => 4.2.9
Author => Swoole Group[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2k-fips 26 Jan 2017
http2 => 1.35.1
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
What is your machine environment used (including version of kernel & php & gcc) ?
CentOS 7.x
Directadmin with PHP, 7.2 nginx as reverse proxy and php-fpm (I guess it's the problem but how to get it worked?)
gcc version 4.8.5 20150623
Linux 3.10.0-957.1.3.el7.x86_64
The text was updated successfully, but these errors were encountered: