Closed StartMoney closed 2 years ago
@StartMoney does your password contain any special characters?
@StartMoney does your password contain any special characters?
No,it always shows this error whatever my password is.
But I seem to have found the reason.
Its the password we set in .env, It did not take effect to elasticsearch-php .
I used the password rest tool changed the password of user "elastic" again , like this:
bin/elasticsearch-reset-password -u elastic -i
seted password to the same in .env.
And use this :
curl -s -XPOST --cacert config/certs/ca/ca.crt -u elastic:mypass_in_.env -H "Content-Type: application/json" https://elasticsearch:9200/_security/user/elastic/_password -d "{\"password\":\"mypass_in_.env\"}"
to set again.
Reset the password again and again , now , it's runs ok.
I think there must be a bug , that when we set password in .env, it's not take effect for all the place where password stored .
when we reset password again and again , it works.
@StartMoney I confirm that elasticsearch-php
do not use any environmental variables for password. You need to pass it using the ClientBuilder::setBasicAuthentication()
method. Anyway, did you solve the issue? I didn't understand when you said that you had to reset the password again and again.
@ezimuel
Hi, thanks for reply.
I followed this to install elasticsearch, and my php is runing by the same docker-compose.yml
https://www.elastic.co/guide/en/elasticsearch/reference/8.2/docker.html
The password is seted in environment , in .env file.
When all is start up , everything is fine except elasticsearch-php .
Then I reseted my password "mypass" to "mypass" , yes , nochanges , the new is the same as the old .
1:
bin/elasticsearch-reset-password -u elastic -i
2:
curl -s -XPOST --cacert config/certs/ca/ca.crt -u elastic:mypass -H "Content-Type: application/json" https://elasticsearch:9200/_security/user/elastic/_password -d "{\"password\":\"mypass\"}"
3:
elasticsearch-php is ok.
“Change password" twice get things back on track.
I don't know why , but it works.
@ezimuel
If you do more tests , rember to use
docker-compose down -v
remove volumes which was made by last test.
or you can use :
` volumes:
and
docker-compose.yml down, and delete
./certs,
./esdata01,
./esdata02and
./esdata03` , then make another test.@StartMoney can you try to follow the instructions reported in the Elasticsearch-php documentation, here? Let me know if you have the same issue, thanks.
OK, I have tested . It's not the problem of Elasticsearch-php ,it's the problem of building elasticsearch with doker-compose.yml Maybe I should post a new comment for docker of elasticsearch. Thanks for reply.
@StartMoney hello,I also encountered the same problem, how did you solve it, my es version is 8.7.1, my command to build the container is: docker run --name es02 --net lnmp_net -p 9200:9200 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -e discovery.type="single-node" -v ./elasticsearch/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:8.7.1
Summary of problem or feature request
There's some error when i connected to elasticsearch use elasticsearch-php . my es server is : https://elasticsearch:9200, all this is configed in $cfg
The ca file is ok :