Memcached can't connect on Windows 7 via PHP - php

On one computer with Windows 7 connecting to memcache runs OK, but on another I get:
Warning: memcache_connect() [function.memcache-connect]: Can't connect to localhost:11211
Code which I'm trying to run is:
$memcache_obj = memcache_connect('localhost', 11211);
I also can't connect via telnet, a failed connection.

start>run type CMD , in the console window type netstat -a -n , do you see something like 0.0.0.0:11211 ... LISTENING ? , if no , probably memcached is not running , or is configured to another port .
In the console , try c:\memcached\memcached.exe -d start 'supposing you have memcached installed in c:\memcached .
to run memcached as windows service , try memcached.exe –d install .
YOU SHOULD START THE CONSOLE AS AN ADMINISTRATOR . try start>all programs > Accessories , then right click on command prompt and run as administrator , then apply all of the above

Memcached is either not running on the machine that you can't connect on or the instance of memcached running on that machine is configured to use a different port.
If you don't have (or want) an instance of memcached one each machine you will need to change "localhost" to the IP of the machine that is running memcached (assuming they are networked).
If it is set up try starting memcached again, and ensure you're using port 11211.

Related

Remote PHP Debugging from within WSL2 in Visual Studio Code

I'm running Windows 10, with a WSL2 Ubuntu instance. I do my development within the WSL2 instance with the "Remote - WSL" extension of Visual Studio Code. So my VSC is running as a WSL2 application, not as a Windows application. I have an additional remote server (I'll refer to this as "Server X" which actually hosts/runs the PHP code. This remote server does not support the use of the "Remote - WSL" extension, so I use an "SFTP" extension to push my changes to this server. And I cannot run the code locally (in either Windows or WSL2) due to the database connection being unsupported.
I'm trying to configure remote debugging of the code on Server X from within VSC running as a WSL2 application (IE: using the "Remote - WSL" extension). The intent is to listen for a browser request to initiate the debug session.
What's happening is when I turn on "Listen for Remote Connection" in VSC when running as a WSL2 application, it doesn't detect the browser when I refresh it. I've determined the reason is because while running as a WSL2 application, my IP is different than when I'm outside WSL (which is where I'm refreshing the browser). So in short, I'm initiating a browser session outside of WSL (IP: 192.168.1.2), the remote server attempts to connect to a debugger at 192.168.1.2:9003, but doesn't find one because my VSC is listening on 192.168.1.3:9003 while it's running as a WSL2 application.
I've confirmed if I instead run VSC as a Windows application (IE: not using Remote - WSL extension on WSL2 instance) everything works fine after adjusting some setting paths to point to Windows PHP rather than WSL2 PHP.
I've been trying to play around with using SSH tunnels to re-route my port 443 traffic from Windows through WSL, but have been unsuccessful so far.
Has anyone run into this issue and have any idea how to get around it? Or is what I'm trying to do unsupported/discouraged?
So WSL runs under the 172.16. 0.0/12 private address range and is not directly accessible by anything external to the host Windows machine. As such, populating xdebug.client_host with this IP, will not work.
My initial idea of using port forwarding was correct, but not in the direction I thought. Instead of redirecting the outgoing web traffic (443 since my site is using SSL) from Windows through WSL, then redirect from WSL to Server X. I instead just needed to redirect the incoming xdebug traffic (9003) from Windows to WSL. (Probably what #Derick was alluding to)
To do this, I left xdebug configured as it normally would have been if WSL wasn't in the picture.
So:
zend_extension=xdebug
xdebug.mode=profile,debug
xdebug.idekey=<ide key value here>
xdebug.client_host=<ip of windows host, as backup>
xdebug.start_with_request=trigger
xdebug.trigger_value=<my trigger value>
xdebug.discover_client_host = 1
Then, using the following PowerShell script on the Windows host to redirect port 9003 from the Windows host to the WSL guest:
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if ($found) {
$remoteport = $matches[0];
}
else {
Write-Output "IP address could not be found";
exit;
}
$ports = #(9003);
for ($i = 0; $i -lt $ports.length; $i++) {
$port = $ports[$i];
Invoke-Expression "netsh interface portproxy delete v4tov4 listenport=$port";
Invoke-Expression "netsh advfirewall firewall delete rule name=$port";
Invoke-Expression "netsh interface portproxy add v4tov4 listenport=$port connectport=$port connectaddress=$remoteport";
Invoke-Expression "netsh advfirewall firewall add rule name=$port dir=in action=allow protocol=TCP localport=$port";
}
Invoke-Expression "netsh interface portproxy show v4tov4";
Above script is modified from the script found here:(https://dev.to/vishnumohanrk/wsl-port-forwarding-2e22)
Which itself is modified from here: (https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723)
Note*: You have to install net-tools in the WSL guest in order for the above script to work, so: sudo apt install net-tools.

Build SSH BD connection with local DB connection laravel

In my laravel application there are 2 connection one is for local server and other one is for remote server.
when I run following command to stablish a tunnel connection for remote server, it returns error
Command ssh -i ~/.ssh/dxdy.pem -N -L 3306:[local_server] dxdy#[remote_server]
Error bind [127.0.0.1]:3306: Address already in use
3306 runs MySQL service in local server. So I cant stop it,
What is the solution for this? How to connect to the remote DB with current local DB ?

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061 "Unknown error")

This may be a duplicate question, however I searched internet for a while, and still couldn't find the solution.
I installed xampp on windows 7. The mysql is running on a random port. However, I can't access mysql from command line. I keep getting this error message:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost'
(10061 "Unknown error").
I enabled mysql for windows services as administrator, and opened the port that the mysql is using through windows firewall settings. But the problem is still not fixed, and I still can not see the port from http://canyouseeme.org/.
Open a command line with administrative privileges. Type the command below.
netstat -a -p tcp | findstr ":138"
Give it the port number that your sql is using instead of ":138" in the above example. Check if the output contains 0.0.0.0 as the IP or not. If it contains your local area network IP then use that IP to connect. Perhaps MySQL is not using all IPs to listen for connections.
maybe your mysql service is not running.
my solution:
open the run and type 'services.msc'
find the mysql count that you build(note:not the mysql, is the mysql count that you build yourself),then run this service.
Find your Path that you are install xampp server on and open CMD Write that
"C:\xampp\mysql\bin\mysqld"
click Enter and Close , reopen CMd and write
mysql -u root
video

Gammu SMS gateway service shows "Error 27"

This is my first experience using Gammu as SMS gateway, and I have a problem with the setup.
This is my system:
Windows 8.1 x64
Gammu 1.33.0 Windows x64
XAMPP 1.8.1
Database connection to MySQL using ODBC
GSM modem used: Wavecom Fastrack M1306B
And here is my smsdrc:
[gammu]
port = com6:
connection = at115200
[smsd]
Service = sql
Driver = odbc
SQL = mysql
host = localmysql
DeliveryReport = sms
logfile = smsdlog
debuglevel = 1
PIN = 1234
commtimeout = 1
sendtimeout = 10
User = root
Password =
# host = localhost
PC = localhost
Database = smsd
And here is my gammudrc :
port = com6:
connection = at115200
What I've did:
Extract the directory of gammu/bin into xampp/htdocs/gammu
Created smsrdc & gammurc files with the configs above
Set the compatibility of gammu-smsd.exe to Run As Administrator
phpmyadmin > Create new db (smsd) > imported the sql from gammu\share\doc\gammu\examples\sql\mysql.sql
My ODBC settings :
(source: kaskus.com)
(I've tested and it's connected)
- I've added the gammu-smsd into windows serices
- test identify by running gammu --identify
- test sending sms manually from console
- test gammu-smsd -c smsdrc, and i had no error at all.
The problem is I couldn't run the gammu-smsd as a service, whether it's manually from the cmd nor started it from the services.
If I started the gammu-smsd from cmd ( gammu-smsd -c smsdrc -s ), the gammu-smsd showed up in the task manager, but disappeared in less than 1 sec.
Whenever I tried to manually start the gammu-smsd service from the Windows Services, it always shows me this kind of error:
(broken image: http://cdn.kaskus.com/images/2014/01/08/270124_20140108085812.png)
I've done some searchs, and what I've found is all about wrong connection into DB, port, or about Run As Administrator. But I'm quite sure it's not from config.
How can I solve this issue, so that I can run the gammu-smsd services properly?
Can you please help me?
Thanks.
Try running not as a service :
gammu-smsd -c smsdrc
in my case that do the job.

How to connect to the proper MySQL database on OS X? (Two mysqld instances running)

I have two instances of MySQL server running on my machine. One is the mysql package that came bundled with MAMP, and the other is a 64 bit installation that I downloaded so I could work with a python library of mine.
This is strictly for development.
Both are running:
:~ zachary$ ps -awwx | grep mysql
1944 ?? 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/MyMachine-2.local.pid
2016 ?? 0:10.17 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/MyMachine-2.local.err --pid-file=/usr/local/mysql/data/MyMachine-2.local.pid
6824 ?? 0:00.02 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log
6894 ?? 0:00.36 /Applications/MAMP/Library/libexec/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql --user=mysql --lower_case_table_names=0 --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmp/mysql/mysql.sock --port=8889
Yet my PHP only seems to want to be able to connect to MAMP's MySQL server. I believe that mysql_connect() lets you specify a port but I'm not sure how to deal with this.
Thanks.
Edit: it seems that MAMP has a preference for its own MySQL server when you use mysql_connect() on a MAMP installation -- not sure why -- can anyone please explain? But I was able to connect to my manually installed MySQL server using this syntax:
mysql_connect(':/tmp/mysql.sock', 'username', 'pw');
It looks like MAMP is running on port 8889 and the other instance is on the default port (3306). To be sure, run netstat -lnp to see what ports all listening processes are using. (Warning: double check the options to netstat, as I am a Linux user, not a Mac user).
AJ right.
And to connect to MySQL server on specific port (other than 3306)
mysql_connect("{$mysqlServerNameOrIp}:{$mysqlSpecificServerPort}", 'username', 'password');

Categories