UPDATED INFO
With dd($clientBuilder->transport->getLastConnection()->getLastRequestInfo());
I could log out the following
"curl" => array:2 [
"error" => "Failed to connect to localhost port 30003: Connection refused"
But the thing is Elasticsearch is available under localhost:30003 via the web browser
The sample output when reaching this site:
{
"name": "xyz",
"cluster_name": "docker-cluster",
...
}
I did configure the host
$clientBuilder = ClientBuilder::create()
->setHosts(['http://localhost:30003/'])
->build();
When I dd($clientBuilder), the host is set to localhost:30003
#serializer: SmartSerializer {#385 …}
#transportSchema: "http"
#host: "localhost:30003"
#path: "/"
Again, the server is up and running, I can reach it via the web browser but I still get the error message:
No alive nodes found in your cluster
Elasticsearch version: 6.7.0
Elasticsearch PHP Version: 6.7.0 (latest)
In my docker-compose file, I'm mapping the port 30003 to 9200
ports:
- "30003:9200"
Elasticsearch did not cause the error.
cURL had an error 7 which means that it could not establish a connection.
My solution I came up with was the following:
$clientBuilder = ClientBuilder::create()
->setHosts([
[
'host' => 'docker.for.mac.localhost',
'port' => '30003'
]
])
->build();
I switched from localhost to docker.for.mac.localhost
This helped because I'm using docker container and each container has a different ip adress
Related
On a Nextcloud install I am receiving the error
No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.
So I have installed APCu, Redis, redis-php and made the required settings in NCs config.php
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '127.0.0.1',
'port' => '6379',
When I test the redis connection
redis-cli ping
I get a
PONG
(This works both w/ localhost and unix socket)
But Nextcloud obviously does not connect to Redis.
The http user is a member of the redis group.
php-redis module is activated.
Solved. The issue was with the location of the above code inside Nextcloud's config.php.
Now it is working as expected.
After running an apt upgrade and a restart of my ubuntu server, cUrl (via Guzzle) repots an error that the host cannot be resolved.
cURL error 6: Could not resolve host: xx.xx (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)
My code is
$client = new Client();
$response = $client->post("https://xx.xx?r=/center/api", [
RequestOptions::HEADERS => [
'X-Requested-With' => 'XMLHttpRequest'
]
]);
This happens randomly and with multiple domains. Meanwhile i was running pings for those domains on the terminal and they were working.
On StackOverflow and Google I could only find solutions that were adding the host to the hosts file but for me that seems to be not a real solution.
I am using Predis PHP library to connect to redis server running on AWS EC2 server. When I try to connect to redis installed on my local system, it works fine. Same code does not work when I try to connect to Redis on AWS EC2. I receive below error.
php_network_getaddresses: getaddrinfo failed: No such host is known. [tcp://my-server-address:6379]
I tried to check connect server on redis-cli using below command and it works fine.
redis-cli -h my-server-address -p 6379
below is the code PHP that I use to connect to Redis.
function config() {
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => 'my-server-address',
'port' => 6379,
'database' => 1,
]);
return $client;
}
I made sure that there is nothing wrong with my server address.
I have the mongod up and running with the command- sudo mongod --journal --rest --config /etc/mongodb.conf, in the logs it says waiting for connections on port 27017
I am trying to connect to mongod from my PHP script using-
$connection = new MongoClient($connectionString, $opts);
where $connectionString = 'mongodb://127.0.0.1:27017'
and $opts= array('replicaSet' => false, 'connect' => true);
Irrespective of the $opts, i "often" get the exception-
'MongoConnectionException' with message: Failed to connect to: 127.0.0.1:27017: send_package: error reading from socket: The socket is closed
The last time I saw such error, I restarted mongod and the exception cleared off. But now it has stuck up again. Sometimes refreshing the browser does the trick. Any clues as to why such undependable behavior??
Thanks.
I'm using symfony2 to connect to MongoDB and when i deleted the port from options list it works !
Try it
I have such network configuration (see link - http://s58.radikal.ru/i160/1110/4c/1c2c5d74edd0.jpg)
Where:
Notebook - contain Apache+php+mongodb+php drivers for mongodb+web project on Zend (Windows)
router - virtual station (nat on 192.168.5.23 interface + ipfw)
natd.conf:
interface le0
same_ports
use_sockets
redirect_port tcp 192.168.5.23:27017 27017
redirect_port tcp 192.168.5.23:27017 27017
ipfw:
allow from any to any
virtual station 2 - contain ONLY mongodb (no php, apache, or mongodb php drivers )
1 - ping from notebook to mongodb host and backward - works.
2 - shell on virtual mongodb host: mongo 192.168.5.20:27017 - connected to notebook's mongodb successfully
3 - attempt to connect from notebook to virtual host cause such error:
C:\mongodb1.8.2\bin>mongo 192.168.9.21:27017
MongoDB shell version: 1.8.2
connecting to: 192.168.9.21:27017/test
Sun Oct 02 22:31:14 Error: couldn't connect to server 192.168.9.21:27017 shell/mongo.js:81
exception: connect failed
4 - attempt to use remote host with DB in php project (www.vm.lcl):
an exception occured while bootstrapping
connecting to vm-db1.lcl failed: Unknown error
Stack Trace:
#0 C:\www\vm-db1.lcl\library\Zirrk\Database\MongoConnection.php(16): Mongo->__construct('vm-db1.lcl')
Please, give me advise - in what direction should I search my mistakes!
Thank a lot!
I've solve this problem by changing rule in natd.conf
redirect_port tcp 192.168.5.23:27017 27017
to
redirect_port tcp 192.168.5.23:27017 192.168.9.21:27017
Before understanding how to fix it, I've create in virtual network (192.168.9.0/24) web-server (192.168.9.11) with apache+php+mongo-php-driver (mongodb - was not installed), and tried to connect to 192.168.9.21
$m = new Mongo("mongodb://192.168.9.21:27017");
This was no sense. I've spent whole day in brainstorm and googling information, but still nothing. (Error was in timeout while connection to server). Then I rest for few hours, and understand, that in my case, all traffic goes through Freebsd-gateway host and add to natd.conf
redirect_port tcp 192.168.9.11:27017 192.168.9.21:27017
reboot gate-way server, and it come to work!