Closed (fixed)
Project:
Node.js integration
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
14 Feb 2013 at 19:38 UTC
Updated:
17 Apr 2016 at 18:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sahithya06 commentedWere you able to resolve this issue? I am currently facing an "Invalid Service Key" error despite maintaining the settings in nodejs.config file and settings.php.
Comment #2
socialnicheguru commentedi am still looking for an answer
Comment #3
socialnicheguru commentedany ideas?
Comment #4
TheMGamer commentedI had the same error and fixed it by enabling the Nodejs Config submodule of Nodejs integration. In the configuration builder, I added the same info as my nodejs.config.js and saved the form. Then it worked. I didn't replace my nodejs.config.js with the new details.
Comment #5
julien66 commentedI can confirm this bug on a fresh setup too.
There is 2 work around I'm aware of at the moment :
- The first is described at #4.
- The second is to leave an empty key on the config file.
I'll have a go more seriously on that issue soon.
++
Comment #6
julien66 commentedThe problem is quite simple.
For every message handled by the backend the first thing that the code performs is to check the service key.
The function that performs this check is fairly simple :
If you didn't enable your config module on and didn't have a go trought it, the "nodejs_service_key" variable is not set at all !
This is leading to compare the default '' string to your actual string defined in your configuration file.
This is also explaining why letting a blank string in your configuration file is actually working.
=> I suggest to add a 'secret key' field to the main configuration form located at admin/config/nodejs/config
And to provide an alert to the end user when an invalid key problem is raised.
Eventually it would be necessary to strip out the 'secret key' field from the config module.
If that make sense, I would submit a patch going that way.
++
Comment #7
julien66 commentedHere's a patch that solve this issue.
It also resolve issue 2181111.
There was a confusion with the service key into the nodejs_config module.
This module was indeed setting the 'nodejs_service_key' variable where it should have just set a config variable for the configuration builder only. There was also no way to set the 'nodejs_service_key' variable without enabling and run the nodejs_config setting form.
This leaded to the error and the behavior described above.
Well... basically here's the full details of what this patch does :
1) Bring a service key field in the main nodejs config form. This field set the real nodejs_service_key variable that will be actually compared with the one stored in the nodejs.config.js.
2) Spread the 'nodejs_service_key' variable from the nodejs_config form. This builder is now defining a 'nodejs_config_service_key' just like it does for others fields (host => nodejs_config_server_host, port => nodejs_config_server_port, protocol => nodejs_config_server_protocol...). Variables defined in this form are just helper variables. They are not used in any way in the real communication process. It is now not different for the service key.
3) Help the end user monitor that something could be wrong with the service key. The http request used to be checked for errors before returning the message. The truth is, a correct http message could still contain an error into the response itself (it's the case when service key isn't matching). The code in this patch also checks for such an error and display a message to the end user if this happens. It also prevents php errors in the case the message is still returned with a service key error.
4) Performs clean uninstall of both modules (main nodejs and nodejs_config).
Tested and approved here.
Cheers !
Comment #8
julien66 commentedComment #9
socialnicheguru commentedin #7 you bring up a good point about nodejs variables.
if I enabled nodejs_config do those variables override others.
For example nodejs_service_key defined in nodejs.install is that overwritten by nodejs_config_service_key if nodejs_config module is enabled?
Are you getting rid of the nodejs_service_key variable and replacing it with nodejs_config_service_key?
In the patch it looks like you are uninstalling items from nodejs_config so do I have to have nodejs_config enabled?
Comment #10
Anonymous (not verified) commentedi committed #2181111: Cleanup variables after uninstalling nodejs.
this patch does too much.
i'd be happier with it if we split it up.
one, just the rename of the service key variable, with an appropriate update hook.
two, the other stuff.
Comment #11
socialnicheguru commentedOMG.... I am so ANGRY.
#6 you were right. the node_server_key variable was not being defined even though I placed it in my settings file.
I did not enable node_config module.
I am including a patch which is totally based on #7 but just for the service key stuff.
Comment #12
glekli commentedThe latest version of the module will hint at the service key being incorrect on the status page if the connection test fails.
That said, as you pointed out, node_config module does need to be enabled in order to configure the service key. Because that submodule is supposed to be a configuration builder for the backend, it is definitely not the most suitable place for the service key. I'll review your patch and commit a fix. Thanks for submitting.
Comment #13
glekli commentedComment #15
glekli commentedThis issue has been addressed. Thanks for the patch. I have made the following changes:
- I skipped the changes in Nodejs::httpRequest. This is a low level method, and we don't want it to put up messages. It wouldn't be appropriate for site visitors to see an error about the service key being invalid. In addition, the error returned by the http call might be needed by the caller function so we don't want to throw that away here.
- I made the service key setting read-only in the configuration builder. There is no point in being able to set it in two different places.