-
Notifications
You must be signed in to change notification settings - Fork 255
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
How to install this? #177
Comments
Learning Composer is well worth the effort. And it's not that complicated.
You should now have a You should not download this code yourself, and not run composer in the downloaded directory (that's why you get that error), but let Composer handle the dependencies for you. |
Step # 2 doesn't work... FYI, I'm under CentOS 7 with PHP 8.2 Also, when you wrote "You should not download this code yourself, and not run composer in the downloaded directory" then what does step # 1 mean? I'm so confused! I've downloaded the GitHub files. I have the directories like examples, lib, tests and bunch of files like .gitignore, composer.json, COPYING.md, Makefile, phpunit.xml.dist, README.md. It's all there. |
All the references to Composer will download the library, its dependencies, and create the autoloader for you. |
Alright, so what I did to install this is:
This seems to work. I can start the server and connect ONE (1) client script to the server and it sends/receives correctly. However, the issue that I'm now running into is that I cannot seem to connect more than a single client at a time to it. The server script I'm using right now is: examples/echoserver.php When I attempt to connect a second client to it, initially it seems to work (it outputs "Creating client" and then "Sending text" or whatever), but all commands time out and are never processed by the server script at all. Is there a reason why it does not accept more than 1 client at a time? How can we make it accept and serve 100 connections at a time? The client script I'm using is: examples/random_client.php I can see in vendor/textalk/websocket/lib/Server.php that the accept() function arbitrarily blocks other incoming connections. Why?
EDIT: After even more investigating, it seems like your WebSocket implementation does not use non blocking sockets (using the native stream_set_blocking() function)... Is there a reason for this? I notice that the current implementation uses fread() in vendor/textalk/websocket/lib/Connection.php which will literally block the whole app until at least 2 bytes come in from the most recently connected socket, making this impossible to use with more than 1 client at a time. |
Well, I came to the conclusion that this is very far from an usable multi-client WS and it has way too many dependencies than is really required. I went with the following for my project: It's a PHP 8.2 compatible multi-client WS server that works perfectly fine and it even supports WSS (WS over SSL so it's secure). Not sure how 152 files could ever beat this simple page of code, but it works flawlessly and it's super easy to tweak too. Hope it helps anyone: https://www.php.net/manual/en/function.stream-socket-server.php#125540 Good luck. |
Well, this repo is a full implementation of the websocket protocol. It's a bit more to it than just I/O. |
Hi, I'm trying to get started with your project and I'm pulling my hair out just trying to "install" it. Is there a simple, complete ZIP archive that contains all the dependencies? I don't understand how to use Composer.
Executing the command in your ReadMe:
composer require textalk/websocket
Returns this error:
Root package 'textalk/websocket' cannot require itself in its composer.json
Composer is the most cryptic thing I've used yet. I don't understand why some projects don't just come in a ZIP like in the past 25 years. Why make it so complicated just to get started?
The text was updated successfully, but these errors were encountered: