Questions › Your php websocket succeeded on localhost, but failed on remote server

4290 asked on 10th Jun 2017

Dear Saran,

I made a little modification to yours on https://www.sanwebe.com/2013/05/chat-using-websocket-php-socket. Thanks for it. It successfully worked at first for the localhost on XAMPP. It was great. But, it was blocked on a remote server nested in WHOIS.COM, a major hosting company. All failed!!! 1. Browser: Chrome, Firefox 2. Hosting Company: WHOIS.COM 3. Service Plan: VPS 4. Tried IPs: 80, 8080, 2028 5. Tried Hosts: localhost, teagege.com:2028, 132.131.312.23:2028 6. domain ip:132.131.312.23:2028 (not on service now) 7. domain:teagege.com:2028

Please see what's wrong!

[index.php]

 var n = 'ws://localhost:80/ph/server.php'; 
   socket = new WebSocket(n);  

[server.php]

  $host = 'localhost'; 
  $port = 80;
  $socketpath = 'ph/server.php'; 
  ......
  $sob = socket_bind($socket, '0.0.0.0', $port);
......
"WebSocket-Origin: $host/rn" .
"WebSocket-Location: ws://$host:$port/$socketpath/rn".

I want to get through this problem even if I got a detour with another easy source code from echo.websocket.org.

Please see.

BEST REGARDS,

    Can You Answer this? Help us answer the question!

      • Answer
      Supports basic Markdown syntax. Excluded syntaxes (Headers, Lists, Blockquotes, Table, Images)