1

I created Google Cloud Virtual Machine instance with bitnami LAMP to launch PHP, MySQL and apache.

  • I've allowed firewall on port 8086 in Google Cloud Platform.

I created two files:

  1. server.php, which is

    • stored in google cloud
    • create server socket on port 8086
    • run using SSH with PHP-CLI
    • socket is binding and listening to port 8086 successfully
  2. client.php, which is

    • stored in my local PC
    • try to connect to IP and PORT(8086) of Google Cloud Instance.

Now problem is, when client.php is trying to connect to server socket on port 8086, it took too long time and then shows error saying that : Connection Timed Out

  1. Any reference regarding web socket communication on google cloud platform ?
  2. Is there any other cost efficient way to do real-time communnication ?
  3. Or should I have to try another VPS like Digital Ocean ?
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Jaldhi Bhatt
  • 125
  • 2
  • 8

3 Answers3

2

Had almost the exact same issue, but with node.

You should allow the port in the firewall on Google Cloud and in the Virtual machine too to get this to work.

In Google Cloud you should open it like this answer: How to open a specific port such as 9090 in Google Compute Engine

If you have ubuntu in your VM, you open the port typing: sudo ufw enable // This allows firewall sudo ufw allow 8086 // This allows your port

Hope it helps.

  • Yup thanks, this solution worked, I had not started server on correct port – Jaldhi Bhatt Feb 09 '18 at 03:55
  • i have open port on google cloud vm instance but how to run php-socket.php on hosting terminal browser shows Firefox can’t establish a connection to the server at wss://domain:9090/beta/chat_socket/php-socket.php. – Gajanan Chitare Feb 14 '19 at 18:40
  • Does Google Compute Engines, vps, run node.js sockets? – Hatim Jul 11 '19 at 03:55
1

i have open port on google cloud vm instance but how to run php-socket.php on hosting terminal

browser shows Firefox can’t establish a connection to the server at wss://domain:9090/beta/chat_socket/php-socket.php.

Gajanan Chitare
  • 349
  • 1
  • 3
  • 4
1

IMPORTANT! It is imperative that you execute the following 3 commands in order not to lose access to the instance by SSH and allow http and https traffic:

sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443

If the above is not executed you will lose access to your VM after closing the SSH console.

@Fernando León: you can edit your answer adding that 3 lines if you like it, thanks.