Skip to content

Websocket server using PHP. Send and Receive data in JSON format, remove error "Could not decode a text frame as UTF-8". Support SSL (wss) and No-SSL (ws)

Notifications You must be signed in to change notification settings

toandd-it/Websocket-Server-PHP-Perfect

Repository files navigation

Websocket Server PHP

Websocket server using PHP. Send and Receive data in JSON format, remove error "Could not decode a text frame as UTF-8". Support SSL (wss) and No-SSL (ws). Support Chat Room

Run on Linux:

  • OpenLiteSpeed: /usr/local/lsws/lsphp73/bin/php /your-dir/wss.php &
  • Apache: /usr/bin/php /your-dir/wss.php &
  • Or: systemctl start phpWs.service (if change config and run file service_create.sh)

Run on Windows:

  • Xampp: C:\xampp\php \your-dir\ws.php

Client using on Javascript:

<script type="text/javascript">
  socketNotice = new WebSocket('wss://your-domain:8090');
  socketNotice.onopen = function(response)
  {
    console.log(response);
  }
  socketNotice.onmessage = function(response)
  { 
    console.log(response);
  }
  socketNotice.onclose = function(response)
  { 
    console.log(response);
  }
  socketNotice.send(JSON.stringify({type: "status", action: "online", rid: '', receiver: [], msg: "", uid: "_my_id", uData: []}));
</script>

About

Websocket server using PHP. Send and Receive data in JSON format, remove error "Could not decode a text frame as UTF-8". Support SSL (wss) and No-SSL (ws)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published