PHP-Websockets | A Websockets server written in PHP | Websocket library

 by   ghedipunk PHP Version: Current License: BSD-3-Clause

kandi X-RAY | PHP-Websockets Summary

kandi X-RAY | PHP-Websockets Summary

PHP-Websockets is a PHP library typically used in Networking, Websocket applications. PHP-Websockets has no vulnerabilities, it has a Permissive License and it has medium support. However PHP-Websockets has 2 bugs. You can download it from GitHub.

A Websockets server written in PHP.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PHP-Websockets has a medium active ecosystem.
              It has 835 star(s) with 356 fork(s). There are 83 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 37 open issues and 66 have been closed. On average issues are closed in 73 days. There are 6 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PHP-Websockets is current.

            kandi-Quality Quality

              PHP-Websockets has 2 bugs (0 blocker, 0 critical, 2 major, 0 minor) and 25 code smells.

            kandi-Security Security

              PHP-Websockets has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PHP-Websockets code analysis shows 0 unresolved vulnerabilities.
              There are 2 security hotspots that need review.

            kandi-License License

              PHP-Websockets is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              PHP-Websockets releases are not available. You will need to build from source code and install.
              PHP-Websockets saves you 257 person hours of effort in developing the same functionality from scratch.
              It has 625 lines of code, 37 functions and 4 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed PHP-Websockets and discovered the below as its top functions. This is intended to give you an instant insight into PHP-Websockets implemented functionality, and help decide if they suit your requirements.
            • Do a handshake
            • Run worker loop .
            • Frames a message
            • Define a message .
            • Extracts headers from the message
            • Split a packet
            • Disconnects from a socket .
            • Convert a string to hex
            • Loop all connected users .
            • Apply the mask
            Get all kandi verified functions for this library.

            PHP-Websockets Key Features

            No Key Features are available at this moment for PHP-Websockets.

            PHP-Websockets Examples and Code Snippets

            No Code Snippets are available at this moment for PHP-Websockets.

            Community Discussions

            QUESTION

            Running PHP WebSocket on Ubuntu
            Asked 2018-Apr-24 at 10:10
            Introduction

            Before getting started with the actual question, I’d like to make a notice of being an extreme beginner to the world of web sockets using PHP. As a matter of fact, I’m still trying to grasp the very basics of it. I do however have lots of experience with sockets overall, from languages such as Java.

            Upon doing my research, I stumbled upon the tutorial from PHP builder, whereas I think myself to having learned how to set socket connections up using this simple library.

            Problem

            Unto the problem we go. For a development server, I have chosen to go with XAMPP—it’ss sort of stayed with me from my Windows days, many years ago. At this very moment, I am using the terminal UI for XAMPP in Ubuntu—meaning, I launch the XAMPP server and then do a killall should I ever wish to close it.

            In the tutorial mentioned above, you enter this information into your PHP document where you keep your server socket:

            ...

            ANSWER

            Answered 2018-Apr-24 at 10:10

            The problem that was occurring at the time was the PHP code being displayed as raw data in the terminal whenever run. I was using short opening tags at the time and did have them enabled in the configuration.

            I did however, resolve the issue, by rewriting the code to use the full opening PHP tags . Perhaps there was more things to configure, maybe the version of PHP I was using was broken. Who knows?

            Source https://stackoverflow.com/questions/42845767

            QUESTION

            PHP websocket disconnect issue
            Asked 2018-Feb-24 at 04:52

            I've tested several libraries (workerman and PHP-Websockets) but in all cases I have the same issue - when I open clients page everything is all right, I have websocket connection with my server, but later it disconnects automatically in a few minutes or less. Is it known issue or is there any methods to handle it? Or should I simply implement some function to force recconection if websocket fails?

            This is a code sample for workerman

            Server test_ws.php

            ...

            ANSWER

            Answered 2018-Feb-24 at 04:52

            As written in this article: "In case of established websocket connection, server or firewall could timeout and terminate the connection after a period of inactivity."

            This is the solution!

            Modified client's page:

            Source https://stackoverflow.com/questions/48932232

            QUESTION

            How to start a PHP Websocket server on Microsoft Azure?
            Asked 2018-Feb-06 at 06:29

            I was able to setup WebSocket on Azure.WebSockets enabled on Azure

            But my issue is : how to start the PHP ws server?

            I have used this sample implementation https://github.com/ghedipunk/PHP-Websockets successfuy on my computer but I am not able to start the server in MS Azure.

            ...

            ANSWER

            Answered 2018-Feb-06 at 06:29

            All Azure Web Apps run in a secure environment called a sandbox. In the sandbox, each app is processed by Microsoft IIS. An app runs through PHP's Command Line Interface (CLI) is not allowed. For more details, please refer to Azure Web App sandbox.

            In order to be able to run PHP-WebSockets in Azure, you need to host in something like a Virtual Machines, Cloud Services, or Containers, rather than Web Apps.

            Source https://stackoverflow.com/questions/48619654

            QUESTION

            Connecting to PHP using Apache's mod_proxy_wstunnel without using 3rd Party APIs
            Asked 2017-Oct-14 at 12:29

            I am new to WebSocket world and even after a week, I still could not find how to use it with PHP without using any 3rd Party Library. Or not sure if it is even possible.

            I have 3 questions,

            1) Do we must need to use some 3rd Party APIs or Libraries like Ratchet, PHP-Push-WebSocket or PHP WebSocket to enable PHP to communicate over WebSocket protocol?

            2) If your answer to above question is yes then what is the advantage/purpose of using Apache's mod_proxy_wstunnel?

            3) If I use any PHP WebSocket 3rd Party Library, then do I still need to enable and use Apache's mod_proxy_wstunnel? If No, then again what is the purpose of Apache's mod_proxy_wstunnel?

            I went through this Using go-websocket behind Apache mod_proxy_wstunnel. In this question, the OP has indicated some go-websocket but unfortunately the link is giving 404 Error and hence I cannot understand if the user has used any 3rd Party API.

            Any help would be highly appreciated. Thanks in advance.

            ...

            ANSWER

            Answered 2017-Oct-14 at 12:29

            PHP is not created for WS. Of course you can do this, but it is full of while (true) and fsock_open [*]. And you have to have access to the shell to run the WS-server with php-cgi. (usually)

            Choose a language that supports threads / asynchronous communication. Now on the top is Node.js. In addition, better use dedicated libraries to support older browsers, etc. If you are thinking about alternatives to ajax then you can use socket.io. If you want to create one-to-all communication (eg chat, broadcast messaging), go one step further and use one of the Bayeux implementations, for example: Faye.

            The mod_proxy_wstunnel extension adds an extra layer to the WS server. Depending on the configuration, it can support DDoS, queue, load-balancing, local port swapping, and https support. But better use this for nginx.

            So, for test you don't need mod_proxy_wstunnel, and on production, you should add an extra layer of security, eg NGINX ws tunelling.

            [*] Sorry, I made some mistakes. PHP has native support for WebSockets. That content is going to set you negatively to WS in PHP.

            Websockets are events, and PHP is poorly managed with it.

            Source https://stackoverflow.com/questions/45163009

            QUESTION

            Ratchet PHP Websocket persistent Ubuntu 16.04
            Asked 2017-May-02 at 14:24

            My websocket file:

            ...

            ANSWER

            Answered 2017-May-02 at 14:24

            Try to use SERVERNAME instead localhost.

            From PHP RATCHET:

            Source https://stackoverflow.com/questions/43613172

            QUESTION

            PHP Websocket undefined in Edge Browser
            Asked 2017-Feb-10 at 11:47

            I developed a multiplayer card game and therefore used a websocket. To implement the websocket in php, I used this library

            I'v put it to my ubuntu server and the program works fine on Chrome Browser and in Firefox (The frontend is implemented using Javascript). Using the Edge Browser, there is an error stating "ReferenceError: WebSocket is undefined". But on the internet I have read that Edge should normally support websockets.

            I already checked, whether the document mode is another IE version, but it is set to edge as well. The exact version is 11.0.0600.18537.

            The following is my code (althoug I don't think that is is a problem with it as it works in the other browsers)

            ...

            ANSWER

            Answered 2017-Feb-10 at 11:47

            Are you sure you are actually writing WebSocket in your code? The error says that Websocket is not defined (with non-capitalized s).

            The actual classname is WebSocket with a capital S.

            Please confirm that the code you pasted as an example is really the same as the one you have in your application.

            EDIT

            After some further discussion in the comments I believe that WebSocket support might be disabled in your browser. WebSocket should be supported in your browser version (11.0.0600.18537) according to my own experiment and Can I Use.

            Source https://stackoverflow.com/questions/41957206

            QUESTION

            PHP Websockets server stops accepting connections after 256 users
            Asked 2017-Jan-25 at 15:18

            I am running a websockets server using https://github.com/ghedipunk/PHP-Websockets/blob/master/websockets.php on an Ubuntu 16 box with PHP7

            After 256 users connect to the websocket, it stops taking connections and I can't figure out why. In the client, I get a 1006 error code (connection was closed abnormally (locally) by the browser implementation) and no further information. The websockets request doesn't appear to make it to the websockets server (which normally echos "Client Connected" right after a socket connection is made).

            In the connect() function, one of the things I do is echo the count of the number of users, sockets and overall memory usage to the log. This problem occurs whenever the user count hits 256 (at which point the socket count is 257 and memory usage around 4Mb). The fact that it happens at 256 makes me think that a limit is being hit somewhere, but I can't find that limit. If I restart the websockets server, everything works fine again.

            From my investigation so far, I have tried and checked:

            • ulimit (says it's unlimited)
            • MySQL connection limit (was set to default, now is 1000, but that didn't help)
            • Increased the PHP memory limit (because why not, just to see)
            • SOMAXCONN is set to 128, so I don't think this is the problem, but I would have to recompile PHP to test it. I haven't tried this yet.
            • Apache: The message I get when the problem occurs is: [proxy:error] [pid 16785] (111)Connection refused: AH00957: WS: attempt to connect to 10.0.0.240:9000 (websockets.mydomain.com) failed, which doesn't tell me much about anything. Apache is running MPM prefork and I have increased the spare servers and MaxRequestWorkers

            I am open to any suggestions as to where to look next or how to get more detail out of the "Connection Refused" error log from apache!

            Thanks

            ...

            ANSWER

            Answered 2017-Jan-25 at 15:18

            It's Apache that holding you up. Try setting the following in your conf file...

            Source https://stackoverflow.com/questions/41854715

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PHP-Websockets

            You can download it from GitHub.
            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

            Broswer Name Earliest Version. Note: Current browser support is available at http://en.wikipedia.org/wiki/WebSocket#Browser_support under the RFC-6455 row.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/ghedipunk/PHP-Websockets.git

          • CLI

            gh repo clone ghedipunk/PHP-Websockets

          • sshUrl

            git@github.com:ghedipunk/PHP-Websockets.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Websocket Libraries

            netty

            by netty

            ws

            by websockets

            websocket

            by gorilla

            websocketd

            by joewalnes

            koel

            by koel

            Try Top Libraries by ghedipunk

            GP-PHP-Websockets

            by ghedipunkPHP

            Gestahl

            by ghedipunkPHP

            GP-Websocket-Examples

            by ghedipunkHTML