I am trying to execute xdebug using dbgp client but I cannot establish a connection with the server.
My phpinfo:
xdebug.remote_enable On
xdebug.remote_handler dbgp
xdebug.remote_host localhost
xdebug.remote_mode req
xdebug.remote_port 9001
I run the client first:
[/usr/local/bin]# ./debugclient
Xdebug Simple DBGp client (0.10.0)
Copyright 2002-2007 by Derick Rethans.
- libedit support: enabled
Waiting for debug server to connect.
I run the script:
# export XDEBUG_CONFIG="idekey=netbeans-xdebug"
# php -dxdebug.remote_enable=1 debug_tmp.php
Check the stat:
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2082 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2083 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2086 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2087 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2095 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2096 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN
tcp 0 0 69.174.52.164:22 111.94.64.239:7531 ESTABLISHED
tcp 0 64 69.174.52.164:22 111.94.64.239:1698 ESTABLISHED
tcp 0 0 127.0.0.1:31750 127.0.0.1:80 TIME_WAIT
tcp 0 0 :::21 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 :::25 :::* LISTEN
tcp 0 0 :::443 :::* LISTEN
tcp 0 0 :::993 :::* LISTEN
tcp 0 0 :::995 :::* LISTEN
tcp 0 0 :::3306 :::* LISTEN
tcp 0 0 :::587 :::* LISTEN
tcp 0 0 :::110 :::* LISTEN
tcp 0 0 :::143 :::* LISTEN
tcp 0 0 :::111 :::* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::465 :::* LISTEN
But still, connection is not established.
Log opened at 2015-01-28 12:22:03
I: Connecting to configured address/port: localhost:9001.
E: Could not connect to client. :-(
Log closed at 2015-01-28 12:22:03
What am I doing wrong?
Nevermind,
the client is set to 9000 for some reason. So I set the xdebug port to 9000, now it's working
Related
I am using beyondcode/laravel-websockets to implement web sockets functionality in Laravel. I am using supervisor in Apache server to run processes for database queues and web sockets. It was working fine until one day I realized that It has stopped working. I haven't made any changes to supervisor.conf file.
This is my supervisor.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/webroot/ROOT/artisan queue:work --tries=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=apache
redirect_stderr=true
stdout_logfile=/var/www/webroot/ROOT/worker.log
stopwaitsecs=3600
startsecs=0
[program:websockets]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/webroot/ROOT/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=apache
When I try to start all supervisor processes using command supervisorctl start all, I get the following output:
laravel-worker:laravel-worker_00: started
websockets:websockets_00: ERROR (spawn error)
Based on this, I manually started the web sockets from my root directory using php artisan websockets:serve and I got below error:
Starting the WebSocket server on port 6001...
RuntimeException
Failed to listen on "tcp://0.0.0.0:6001": Address already in use (EADDRINUSE)
at vendor/react/socket/src/TcpServer.php:184
180▕ // #link https://3v4l.org/3qOBl
181▕ $errno = SocketServer::errno($errstr);
182▕ }
183▕
➜ 184▕ throw new \RuntimeException(
185▕ 'Failed to listen on "' . $uri . '": ' . $errstr . SocketServer::errconst($errno),
186▕ $errno
187▕ );
188▕ }
+17 vendor frames
18 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
As mentioned in the exception, the port I am using for web sockets i.e. 6001 is already in use. I listed the used ports using the command netstat -tulpn and it shows that 6001 port is being used by php. This is the output:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 23974/php
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:749 0.0.0.0:* -
udp6 0 0 :::111 :::* -
udp6 0 0 :::749 :::* -
I killed the process using kill 23974 but it reopens quickly and uses the same port again automatically. I am not being able to figure what exactly is using this port. I tried reconfiguring, restarting supervisor, redeploying my code etc. but nothing worked. What might be the possible issues here?
I am running in Google Compute Engine Node on port 80 and Apache httpd on port 81. But when I try to visit port 81 by the url, which is the IP Address, XX.XXX.XXX.XXX:81, the browser redirects the request to 80 which is the node app. How can I make it work?
ports.conf
Listen 81
sites-enabled/000-default.conf
<VirtualHost *:81>
....
</VirtualHost>
What am I missing? Thank you.
When I deploy the Node app, I have run the following command:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
netstat -l
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:3000 [::]:* LISTEN
udp 0 0 instance.c:ntp 0.0.0.0:*
udp 0 0 localhost:ntp 0.0.0.0:*
udp 0 0 0.0.0.0:ntp 0.0.0.0:*
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] SEQPACKET LISTENING 8972 /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 12342 /var/run/mysqld/mysqld.sock
unix 2 [ ACC ] STREAM LISTENING 9021 /run/systemd/fsck.progress
unix 2 [ ACC ] STREAM LISTENING 27705 /home/myuser/.forever/sock/worker.1508373192880gMA.sock
unix 2 [ ACC ] STREAM LISTENING 10413 /run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 8907 /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 8928 /run/systemd/journal/stdout
unix 2 [ ACC ] STREAM LISTENING 10225 /run/uuidd/request
I have installed apache and php on a linux server CentOS 6.4. I followed these steps
yum install -y httpd
/sbin/service httpd restart
yum install -y php php-mysql
yum install -y mod_ssl openssl
/sbin/service httpd restart
service iptables stop
I changed the ServerName in /etc/httpd/conf/httpd.conf from
#ServerName www.example.com:80
to
ServerName 172.32.35.14 (ip address of the server)
/sbin/service httpd restart
I have a php sample pas with the following code:
<?php
phpinfo();
?>
But when I try to access the page http://172.32.35.14/info.php from my local machine it says "Problem loading page". Whereas, I get proper response when connected to the page from 172.32.35.15
My ISP doesnt block http requests.
172.* network is a VPN. I connected to the VPN, able to ping the machine, do a ssh connection to the machine using putty. But when I cannot access the php page from my local machine.
What am I missing? Please advice
netstat -tulpn output is:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1235/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 4406/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 4198/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4636/master
tcp 0 0 0.0.0.0:52330 0.0.0.0:* LISTEN 1253/rpc.statd
tcp 0 0 :::111 :::* LISTEN 1235/rpcbind
tcp 0 0 :::80 :::* LISTEN 30170/httpd
tcp 0 0 :::22 :::* LISTEN 4406/sshd
tcp 0 0 ::1:631 :::* LISTEN 4198/cupsd
tcp 0 0 ::1:25 :::* LISTEN 4636/master
tcp 0 0 :::443 :::* LISTEN 30170/httpd
tcp 0 0 :::46690 :::* LISTEN 1253/rpc.statd
udp 0 0 0.0.0.0:1005 0.0.0.0:* 1253/rpc.statd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1235/rpcbind
udp 0 0 0.0.0.0:631 0.0.0.0:* 4198/cupsd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1129/dhclient
udp 0 0 0.0.0.0:986 0.0.0.0:* 1235/rpcbind
udp 0 0 0.0.0.0:39783 0.0.0.0:* 1253/rpc.statd
udp 0 0 :::111 :::* 1235/rpcbind
udp 0 0 :::38152 :::* 1253/rpc.statd
udp 0 0 :::986 :::* 1235/rpcbind
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Please confirm your server(172.32.35.14) where you have install php and mysql right?
What is your local machine ip?
Please run tracert and nslookup command from your local machine:
tracert 172.32.35.14
nslookup 172.32.35.14
and see where packets drops.
My PHP script opens port using socket like:
$socket = stream_socket_server('tcp://127.0.0.1:' . $this->port, $errno, $errstr);
For example say port is 58889.
I cannot connect to port from telnet (Connection refused).
Here is what 'netstat -plunt' command shows:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:58889 0.0.0.0:* LISTEN 13849/php
tcp 0 0 127.0.0.1:58890 0.0.0.0:* LISTEN 13841/php
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:58891 0.0.0.0:* LISTEN 13857/php
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::25 :::* LISTEN -
There is no special firewall rules on hosting provider. How to fix it?
The issue is that the TCP server is only listening for connections on the localhost IP address.
This will only allow connections from the 'local' machine.
To specify to listen for connections on all the IP addresses on the machine, which will allow connections from external machines, then use an IP Address of '0.0.0.0' (IPv4):
stream_socket_server('tcp://0.0.0.0:' . $this->port, $errno, $errstr);
I'm trying to get a value from a netcat connection started at a php file, but it dies with:
localhost [127.0.0.1] 2000 (?) : Connection refused
I don't know why but it works well if I ssh it as apache user (www-data), this is what I've done:
1) Start an endless loop serving a date with a little delay:
$ (while true; do nc -l -p 2000 -c "sleep 5; date"; done)&
2) Check if is working:
$ su www-data
$ nc localhost 2000
Fri Oct 16 21:33:20 COT 2009
3) Create /var/www/test.php as follows:
<pre><?php
exec('nc localhost 2000>>/var/www/dates.txt 2>>/var/www/errors.txt &');
?></pre>
4) Run it on a browser:
http://myserver.com/test.php
5) Finally take a look at both txt's, dates is empty (nothing like the response in #2) and errors has the "Connection refused" error.
The server is a LAMP cluster running Ubuntu Server 9.04 with DRBD and Heartbeat.
What is driving me crazy is that this test.php works well in my laptop (LAMP on Ubuntu Desktop 9.04) and the server seems to have the ports already open and listening:
$ netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4743 0.0.0.0:* LISTEN 2326/openhpid
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3364/mysqld
tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN 9510/nc
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3470/apache2
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2320/sshd
tcp 0 0 127.0.0.1:3551 0.0.0.0:* LISTEN 2354/apcupsd
tcp6 0 0 :::22 :::* LISTEN 2320/sshd
I think that this is a programming related question right?, if not just close it without any comments please.
Thank in advanced!!!
Well, it was a permission problem after all... fixed editing /etc/sudoers with visudo to add:
www-data ALL = NOPASSWD: /bin/nc