Unable to connect to Websocket using roaming envirionment

I use Vagrant with puphpet , the environment is PHP 5.5 + ubuntu 12.04 + apache + mysql. My Vagrant VM ip: 192.168.11.11, the local hosts of the computers point to 192.168.11.11 reactphp.dev , and it works.

And I use this code: https://github.com/muuknl/phprealtimechat to test websocket.

Then I will visit reactphp.dev in my Chrome browser, and I started the script server using: php bin/server.php , and after entering the username I got the error:

WebSocket connection to 'ws://192.168.11.11:2000/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

This works fine when I change the websocket ip address to `ws: //127.0.0.1: 2000 / ', but why doesn't it work if I go to my VM IP address?

+6
source share
1 answer

Some time passed when I did not use PuPHPet, but when I had problems connecting through the port (minus port 22), I had to issue the sudo ufw disable machine.

If uwf not the control firewall of your vm, try sudo service iptables stop or sudo iptables -F .

They may have changed their behavior since then, but it's good to try.

An SSH tunnel (through open port 22) can allow you to access local port 2000 , which is optimized. Actual 2000 VM port may be limited due to firewall.

Try it and tell me if it works. If not, I will dig deeper.

+1
source

Source: https://habr.com/ru/post/983894/


All Articles