Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port configuration failing using .env #64

Open
ngilain opened this issue Oct 30, 2019 · 3 comments
Open

Port configuration failing using .env #64

ngilain opened this issue Oct 30, 2019 · 3 comments

Comments

@ngilain
Copy link

ngilain commented Oct 30, 2019

Hello,

I have encountered a strange bug regarding the configuration of the port in the neo4j.yml file on an application in Symfony 4.3.

If the port is 'hard' configured - aka 7687 -, all is ok. But if we refer instead to an environment variable with the syntax '%env(NEO4J_PORT)%', everything crumbles and the connection crashes with this following error message:

In StreamSocket.php line 203:
                                                                               
  Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known        

The crazy thing is that the port is the only configuration leading to that bug, using environment variables to configure the host or the user is ok.

Digging into the bundle, I finally found the origin of the problem: the port is cast into an integer in the depency injection: https://github.com/neo4j-contrib/neo4j-symfony/blob/master/DependencyInjection/Neo4jExtension.php#L206

That cast is ok if the port is 'hard' configured, but if someone want to use an environment variable it's no longer working because Symfony does not inject at this step the values ​​of the variable but a proxy which will be solved later, in my example env_e68e500d790ef07c_NEO4J_PORT_2f05a784d88d91a07d4331d3f53a7cab. Casting this string into an integer returns 0, causing a lot of troubles in cascade.

Is it possible to correct this point? The solution is to use the pattern '% s: //% s:% s @% s:% s' instead of '% s: //% s:% s @% s:% d'

Thank you !

@xavismeh
Copy link
Collaborator

xavismeh commented Nov 4, 2019

Hello,

Have you tried to use %env(resolve:NEO4J_PORT)%?
Also, please note that this "syntax" is deprecated in Symfony best practices, and recommend to use a dsn

@ngilain
Copy link
Author

ngilain commented Nov 6, 2019

Hello,

configuring a dsn instead of 'individual parameters' does the job as no alteration of the value provided in the conf is done in the dependency injection.

But using %env(resolve:NEO4J_PORT)% doesn't solve the problem as it still gives a proxy instead of a value, this proxy still being cast into 0 via the sprintf.

So I can make the bundle working using the dsn conf and I will do that, but be advised that the bundle is buggy if using the 'individual port parameter' as mentionned here :https://github.com/neo4j-contrib/neo4j-symfony/blob/master/README.md#full-configuration in conjunction with .env file.

Thank you for your help !

@xavismeh
Copy link
Collaborator

xavismeh commented Nov 6, 2019

Indeed, this port parameter used to be there to prevent BC. But it seems something needs to be done anyhow + emphasis in the doc that dsn parameter is preferred over "individual" parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants