7 Replies - 837 Views - Last Post: 26 January 2013 - 09:45 PM Rate Topic: -----

#1 chiefofgxbxl  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 43
  • Joined: 24-June 09

PHP WebSocket connects via localhost only

Posted 26 January 2013 - 05:13 PM

I've been looking into using websockets for the past few days in a project I'm working on in which users can collaboratively edit a document together in real time (sort of like Google Docs, but much simpler...). Unfortunately I am being held back by a problem with the PHP Websocket github project located here: https://github.com/F...PWebSocket-Chat

There is a test machine I am running in my house to run the server. Following some guidelines from another tutorial, I am using XAMPP, which includes Apache. When I start the server up with the configurations set to localhost:6118 (the machine running the server) I am able to run the client.html in multiple tabs and have users message each other on the server itself. However, when I try to use another computer within my network to try this it cannot connect. Of course, in the client.html file it is necessary to set the IP not to local host, but to point it to 192.168.1.12:6118 (the internal IP of the server). Even this does not work.

Thus, the server.php file included in the github project seems to work alright -- the problem I encounter is when I try to get other users, such as on my network and other users connecting externally outside my network. They will not connect, despite the comments saying to change the IP in the client.html and server.php differently, depending on if you want to run the server only on the local machine or open to the internet.

So far I have tried:
  • Port forwarding on port 6118
  • Testing various combinations of ports and IPs
  • Verifying that the server's security configuration wizard is set properly to allow connections on port 6118
  • Checking that php_sockets.dll is in \ext\ directory
  • Editing php.ini settings to include the php_sockets.dll correctly


Does anyone know the problem here? I still feel like something is wrong with the port, but I'm not completely sure.

I also understand that web sockets are still in development, and that PHP sometimes gets a poor reputation, among other implementations, with managing the sockets. It would further be appreciated if someone led me to a web host that supported working with web sockets. I've heard that Amazon (AWS) possibly offers this sort of support.

This post has been edited by chiefofgxbxl: 26 January 2013 - 05:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: PHP WebSocket connects via localhost only

#2 no2pencil  Icon User is online

  • Dic Head
  • member icon

Reputation: 5165
  • View blog
  • Posts: 26,840
  • Joined: 10-May 07

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 05:19 PM

Does the firewall on the machine block that port?
Was This Post Helpful? 0
  • +
  • -

#3 chiefofgxbxl  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 43
  • Joined: 24-June 09

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 05:28 PM

No. A while back I had a server written in VB.net to listen to the port, but now I'm messing around with a web socket server. The port 6118 is listed as a port to be allowed through windows firewall, on Windows Server 2003.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Dic Head
  • member icon

Reputation: 5165
  • View blog
  • Posts: 26,840
  • Joined: 10-May 07

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 05:34 PM

YOu are positive that there isn't already a session holding the port? Reboot & try again?
Was This Post Helpful? 0
  • +
  • -

#5 chiefofgxbxl  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 43
  • Joined: 24-June 09

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 05:49 PM

Nothing should be using that port. We created the entry in the port forwarding to be sure that it is to be used only for this server instance.
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is online

  • Dic Head
  • member icon

Reputation: 5165
  • View blog
  • Posts: 26,840
  • Joined: 10-May 07

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 05:52 PM

If you tested it on localhost, & it's hung, then the server will not accept new connections. Internal or external. it isn't the port, it's the server.
Was This Post Helpful? 0
  • +
  • -

#7 chiefofgxbxl  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 43
  • Joined: 24-June 09

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 06:37 PM

Ok, thanks for the help, but can't the server be refusing the port? An online service to check open ports said it was closed: Reason: Connection refused. I did: netstat -an, and it did list the machine as "LISTENING" on port 6118, but telnet 192.168.1.12 6118 won't allow a connection.

The firewall settings has an exception, and security configuration manager also has it listed as a valid port. I've done some of the things that other sites have listen, such as checking the router settings and whatnot, so any ideas why this port just won't give in?

When you say the problem isn't the port, it's the server, what exactly do you mean? The server must be refusing any attempt at a connection except through itself..

This post has been edited by chiefofgxbxl: 26 January 2013 - 06:38 PM

Was This Post Helpful? 0
  • +
  • -

#8 no2pencil  Icon User is online

  • Dic Head
  • member icon

Reputation: 5165
  • View blog
  • Posts: 26,840
  • Joined: 10-May 07

Re: PHP WebSocket connects via localhost only

Posted 26 January 2013 - 09:45 PM

Sorry, I meant to say the 'port forwarding'.

This post has been edited by Dormilich: 27 January 2013 - 01:29 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1