Can't connect Websocket when using vagrant envirionment - php

I'm using Vagrant box using puphpet, the environment is PHP 5.5 + ubuntu 12.04 + apache + mysql. My Vagrant VM ip: 192.168.11.11, local machine hosts points to 192.168.11.11 reactphp.dev, and it works.
And, I'm using this code: https://github.com/muuknl/phprealtimechat to test websocket.
Then I visit reactphp.dev in my Chrome browser, and I start server script using: php bin/server.php, and after I type in the username I just got the error:
WebSocket connection to 'ws://192.168.11.11:2000/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
It works well when I changed the websocket ip to `ws://127.0.0.1:2000/', but why it does not work if I change to my VM's ip address?

It's been a while I haven't used PuPHPet, but when I had troubles connecting through the port (minus port 22), I've had to issue the command sudo ufw disable in the vagrant machine.
If uwf isn't the managing firewall of your vm, try sudo service iptables stop, or sudo iptables -F.
Perhaps they've changed the behavior since then, but it's still good to try.
The SSH tunnel (over the opened port 22) might allow you to access the local port 2000, which is proxified over. The actual port 2000 of the VM might be limited due to firewall.
Try it, and tell me if this works. If not, I'll dig in deeper.

Related

Connecting to MySQL Server on Ubuntu not possible

I have set up a raspberry PI 4 with Ubuntu. Apache, PHP, mysql and phpmyadmin are installed and working fine. So when I am trying to connect from another network with my windows device over MySQL Workbench there is an error occuring.
error
Checked: port forwarding on port 80 is open. checked binding ip in mysqld.conf (maybe I made a mistake there) when I try to change the port in this configuration file to 80 and restart "sudo service mysql restart" this error occure "Job for mysql.service failed because the control process exited with error code"
So maybe mysql is not listening to port 80. I have checked sudo lsof -i :80. Only found records from apache listening to port 80.
I am trying for three days now to connect to the database.
Thank you for your help guys!
By default, mysql listens on port 3306, so if you are trying to connect directly to mysql, that could be the issue. Port 80 and 443 are for http/https respectively.
You can't set the port to port 80 because apache needs that port to listen for http requests.
Try setting the port back to 3306 on the mysql host machine and seeing if that works. You may also need to open that port on the host machine as well.

How to fix localhost refused to connect on Windows 10 Wamp server and Xampp?

I've installed WAMP Server on Windows 10 and it was working fine. But when I try to load localhost today it gives me refused to connect error. I've read some questions on Stack Overflow and tried their answers but no luck.
Re-installed wamp (also tried xampp. non of these work)
IIS is off
Web Development.. thing in services is not running.
Tried netstat -aon and port 80 PID is same as wampapache64 process.
changed listening port to 81 in httpd.conf in wamp => apache =>
Cleared browser cache
Wamp icon is green
Can't connect using 127.0.0.1
Nothing works.
Screenshots:
I will assume the wamp icon in the system tray is green. I think you should start tracing the root cause from the apache error/access log.
Try change the http port to 8080 and access localhost:8080. left click the wamp icon in the taskbar, go to apache > httpd.conf and edit this file: change "listen to port .. 80" to 8080.
Try the hosts file with only the initial records and test.
127.0.0.1 localhost
::1 localhost
If you are facing the error from the apache errors log file
(OS 10038)An operation was attempted on something that is not a socket. : AH00332: winnt_accept: getsockname error on listening socket, is IPv6 available?
then do the following:
* Run 'command prompt' as administrator and run the command netsh winsock reset . and restart the PC.
Skype default port is 80 and this might be having a conflict .. try to change it from Skype options.
Finally make sure the antivirus or any firewall you are having is not blocking your application requests.
firstly, uninstall wampp as well as xampp server from your PC. Also delete the wampp/xampp folders in C drive.
then install wampserver 2.0i from the link below-
wampserver 2.0i
after installation, start wamppserver and try to open localhost in chrome browser.
if localhost doesnt work, then try localhost:80
hope it helps!!

How to enable PHP's built-in web server on wercker

I have setup my wercker.yml file with the following step midway:
- script:
name: Serve application
code: php -S localhost:8000 >> /dev/null &
That appears to run, however, in another step when I try cURL to http://localhost:8000 I get the following:
curl: (7) Failed to connect to localhost port 8000: Connection refused
It does it for all ports, not just 8000. Has anyone else managed to get PHP's in built server working in wercker, or open any ports?
Assuming you're using the wercker CLI and trying to set up a development pipeline, you need to use wercker dev with the --publish 8000 argument. This will forward the traffic from your host on port 8000 to the container on port 8000.
Also, if you're using boot2docker, you can't specify localhost, since boot2docker spins up a VM that runs docker. In that case you'll need to use your boot2docker IP, which you can find by running the boot2docker ip command.

MemcachePool::get(): Server localhost (tcp 11211, udp 0) failed with: Network timeout

I have been working with Memcache and PHP for a long time and was everything great but now I have been getting this error after every 10 to 15 minutes.
MemcachePool::get(): Server localhost (tcp 11211, udp 0) failed with: Network timeout
I thought it might be due to Firewall or something like that so I turned of my Firewall but yet didn't stop giving this message.
After every error I have to restart my memcache.
And it's Memcache not with D on windows 7 machine with PHP 5.4 MSVC9 TS version. I can not understand what to do now with this Network Timeout issue. What can be done to solve this.
Currently, currently I have only one local machine with windows 7 so cannot make a cluster of Memcache or install Memcache(D).
Unsure if it is a memcache Daemon or client issue.
I had the same issue, with php on Windows 10 and Memcached installed on Ubuntu (running in the Windows Subsystem for Linux)
Im my case, the problem was that localhost resolves to [::1]:
>ping localhost
Pinging SURFACE-PRO-FRA [::1] with 32 bytes of data:
And Memcached by default listens only on 127.0.0.1.
To solve the issue, you can make Memcached listens also on the ipv6:
$ sudo vi /etc/memcached.conf
Replace
-l 127.0.0.1
with:
-l 127.0.0.1,::1
And then
sudo service memcached restart
Or alternatively, make your app connect to 127.0.0.1 instead of localhost.

Php connection to Sphinx refused

I have installed Sphinx on my server and everything seems to working, except that when I run the test.php from web browser, I am getting this error:
Query failed: connection to localhost:9312 failed (errno=111, msg=Connection refused).
I have searched online, including stack overflow, almost all suggestions were make sure the searchd service is running, and it's listening on the right port. I can say yes to both questions because if run the same test program directly in command line, everything works. I understand that the hosting provider may not have opened the port, but the port should be listening with the server, right? The fact that it works under command line should confirm that the service is listening on that port and the php program is able to get through to it. So I don't understand why the same program run from the web browser rejects the connection.
I have also enabled fsockopen in php.ini.
Any suggestion to help understand why the connection is rejected or even better how to solve it is very welcome!
Thanks
You can try this:
check your sphinx.conf and make sure that 9312 is your spinx's port (my default port was 3312)
change localhost to 127.0.0.1
If this doesn't work for you check if port is open, you can do it with nmap
sudo apt-get install nmap
nmap 127.0.0.1 -p 9312

Categories