When trying to see the server stats, I noticed my server.js was writing into console:
Invalid service key "", expecting "GXZAYZjR7iDKzw4CcV9ZLYJQfDgWz8PQ"
My configuration was set to use service key of "GXZAYZjR7iDKzw4CcV9ZLYJQfDgWz8PQ". It was configured in UI provided by nodejs_config module.
I found out that the service key was saved into variable 'nodejs_config_serviceKey', not into variable 'nodejs_service_key' as nodejs_get_config() and nodejs_is_valid_service_key() expects.
However, after fixing that I found out also that nodejs server expect the service key to be provided in HTTP headers. Server stats callback function nodejs_get_server_stats() calls for nodejs server without headers at all leaving the service key not be provided at all to nodejs server.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | nodejs-server-vars-1260974-9.patch | 715 bytes | carnau |
Comments
Comment #1
Anonymous (not verified) commentedclosing, the server stats code has been removed, and bugs in the config UI module fixed during the code sprint at drupalcon london.
Comment #3
imiksuI installed once again (7.x-1.0-beta6) and still having same issue (getting console.log about service key). Is it related to my Node.js version? I'm using v0.4.11.
Comment #4
imiksuComment #5
Anonymous (not verified) commentedyep, confirmed, fixed with this commit:
http://drupalcode.org/project/nodejs.git/commit/952f867
Comment #6
danielm commentedCan be put also in the version 6X
Comment #7
carnau commentedChanged status, 'because for 6.x version it's not fixed.
Also, changing these lines don't affect the bug and is still reproducible(in D6). I think JSON is empty.
Comment #8
julien commentedJust commited on the 6.x branch. #0ac5049
@carnau after this commit i'm not able to reproduce this issue, but after reading up @ #1, can you confirm me that it's fixed?
Comment #9
carnau commentedYes, I'm still having this issue. I'll try to trace it.
Also, I provide a patch because in the last version, host and port nodejs variables in nodejs_get_config() are wrong, and always is using default values.
Comment #10
carnau commentedWell, I see the problem here.
In nodejs.module we get the serviceKey value like this:
This variable isn't from this module, but nodejs_config. So, if you don't enable this extra module and also fill the admin form, it always return blank because the variable not exists.
Also, I found another bug in nodejs_config admin form. The first value says:
So, if you want to leave this field blank you can't, because the required option is TRUE. Should be FALSE.
Comment #11
carnau commentedOne question about this. I'm getting this error on nodejs side :
If I enter the url nodejs/message with my browser, it shows:
I found that nodejs_message_handler() function is who returns this message:
So, the question is, ¿Where $_POST['serviceKey'] is initialized? I dumped it but returns NULL.
Comment #12
julien commentedAre you using the 6.x-1.x-dev branch or the 6.x-1.0 ?
I confirm that to use the service key feature, you need to set it correctly in both the js config file and also in the Drupal backend settings form.
if you get this error from the server:
It may come from a wrong config file, like your drupal hostname.
Comment #13
julien commentedComment #14
carnau commentedYes, it was a bad configuration file, damn virtualhosts... It's working now.
Now I'm using the dev version, and I can't reproduce the 'Invalid service key' message on the nodejs side, so I assume it's working now.
I'm still working on find why I recive the "{ "error": "Invalid service key." }" if I enter directly from the browser to the 'nodejs/message' path.
Comment #15
Anonymous (not verified) commentedthe reason you recieve that if you got to 'nodejs/message' is because things are working as designed.
the point of the service key is to secure the back-channel between the drupal server and node.js server process.
Comment #16
sahithya06 commentedHello Carnauro
What steps did you take to resolve the Invalid Service Key issue? I am able to see the messages being pushed to the server in the logs, but am unable to see them inside the chatroom and I am wondering if it is because of this error.
I have maintained the same service key in the nodejs config file and in drupal backend settings.
Would appreciate a quick reply!
Thanks,
Sahithya
Comment #17
sahithya06 commentedHi beejeebus
I am getting the "Invalid Service Key" error and have been unable to resolve it. I have maintained the service key in settings.php as well.
My configurations are as below :
settings = {
scheme: 'http',
port: 5000,
host: '127.0.0.1',
resource: '/socket.io',
serviceKey: 'xyz',
backend: {
port: 80,
host: '127.0.0.1',
scheme: 'http',
basePath: '',
messagePath: '/nodejs/message/'
},
debug: false,
sslKeyPath: '',
sslCertPath: '',
sslCAPath: '',
baseAuthPath: '/nodejs/',
publishUrl: 'publish',
kickUserUrl: 'user/kick/:uid',
logoutUserUrl: 'user/logout/:authtoken',
addUserToChannelUrl: 'user/channel/add/:channel/:uid',
removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
addChannelUrl: 'channel/add/:channel',
removeChannelUrl: 'channel/remove/:channel',
setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
toggleDebugUrl: 'debug/toggle',
contentTokenUrl: 'content/token',
publishMessageToContentChannelUrl: 'content/token/message',
extensions: [],
clientsCanWriteToChannels: false,
clientsCanWriteToClients: false,
transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
jsMinification: true,
jsEtag: true,
logLevel: 1
};
It would be great if you could let me know what exactly could be causing this issue. I am able to see that the messages are being pushed correctly through the logs, however, I am unable to view the messages inside the chatroom. Are the issues tied?
Would really appreciate a quick reply!
Thanks,
Sahithya
Comment #18
Ari Gold commentedI needed to use quotes:
"serviceKey":"my service key",