1

I have installed node.js server on shared hosting.I have drupal site in which I am using node.js integration module to connect to node.js server. But whenever I am trying to broadcast message from admin panel, I am getting this error message "Error reaching the Node.js server "Error reaching the Node.js server at "nodejs/publish" with {"data":{"somecustomdata":"http://www.google.ca"},"channel":"nodejs_user_1","callback":"myowncallback","clientSocketId":""} "%{"data":{"somecustomdata":"http://www.google.ca"},"channel":"nodejs_user_1","callback":"myowncallback","clientSocketId":""}": [404] Not Found." in db log.

Any help would be appreciated.

Sumit
  • 83
  • 2
  • 11
  • just a tip. If answer satisfied you and the problem is resolved, you are expected to vote on the answers you liked, and accept the best answer. (To motivate helping people continue being helpful ;-) ) More info: http://stackoverflow.com/tour – alandarev Apr 05 '14 at 07:25

3 Answers3

1

It is very likely one of two things:

  1. Drupal server is accessing wrong URI.
  2. Node.js Server is not listening to the URI you expect it to.

Of course something less obvious might cause errors, but please verify those two before proceeding.

Best would be to get your Drupal server print in error logs the URI it is trying to access, and manually verify you can access it within your browser, or another tool.

alandarev
  • 8,349
  • 2
  • 34
  • 43
  • Can you please tell me how to access nodejs from browser. – Sumit Apr 03 '14 at 13:11
  • Not before you do your homework ;-) Node.js is a server which needs to be running as a process. Accessing it, is similar to accessing any other http(s) server - by entering URL in your address bar. I advice you trying to manually connect to your node.js server before trying to make Drupal connect to it. To learn about Node.js find yourself comfortable at: http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js – alandarev Apr 03 '14 at 13:26
  • Thanks for your help.I have checked on new port number using this code http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }).listen(49160); but its response is displayed in the browser until we cancel the node command.After canceling the command the response will no longer exist and the server is also not responding on that port for node.js. – Sumit Apr 03 '14 at 15:13
  • You close the server, you no longer get response from it, sounds logical to me. What is the problem? – alandarev Apr 03 '14 at 16:01
  • Actually the problem is after opening the node.js server and in between I tries to send notification using drupal nodejs api function then in command line it is saying that "publishmessagetochannel" the channel "channel name" does not exist. – Sumit Apr 03 '14 at 16:28
  • Thanks for your help alandrav.Now my app is working well with nodejs server. – Sumit Apr 04 '14 at 16:42
1

Thanks "alandrev" for your help.I have resolved that issue on the same day but I forgot to add my mistake.Actually I was not configuring the nodejs correctly.I was using the incorrect port number on backend settings in nodejs.config.js file.The correct settings mentioned below:

backendSettings = {
  "scheme":"https",
  "host":"yourhostname",
  "port":"port number which is not already in use",
  'sslKeyPath': 'key file path for ssl enabled site otherwise leave empty',
  'sslCertPath': 'certificate path for ssl enabled site otherwise leave empty',
  'sslCAPath': '',
  "resource":"/socket.io",
  "baseAuthPath": '/nodejs/',
  "publishUrl":"publish",
  "serviceKey":"",
  "backend":{
  "port":443,
   "scheme": 'https or http',
  "host":"yourhostname",
  "messagePath":"/nodejs/message/"},
  "clientsCanWriteToChannels":false,
  "clientsCanWriteToClients":false,
  "extensions":"",
  "debug":false,
  "addUserToChannelUrl": 'user/channel/add/:channel/:uid',
   "publishMessageToContentChannelUrl": 'content/token/message',
  "jsMinification":true,
  "jsEtag":true,
  "logLevel":1}; 
Sumit
  • 83
  • 2
  • 11
0

Solved this same issue by adding "polling" to the transport

backendSettings = {
  "scheme":"http",
  "host":"localhost",
  "port":8081,
  "key":"/path/to/key/file",
  "cert":"/path/to/cert/file",
  "resource":"/socket.io",
  "publishUrl":"publish",
  "serviceKey":"SERVICE KEY",
  "backend":{
  "port":80,
  "host":"localhost",
  "messagePath":"/mysite/nodejs/message/"},
  "clientsCanWriteToChannels":true,
  "clientsCanWriteToClients":true,
  "extensions":"",
  "debug":true,
  "transports":["websocket","polling",
      "flashsocket",
      "htmlfile",
      "xhr-polling",
      "jsonp-polling"],
  "jsMinification":true,
  "jsEtag":true,
  "logLevel":1};
benka
  • 4,732
  • 35
  • 47
  • 58
Bipin K
  • 105
  • 4