I followed the instructions, but I can not get Node JS working. There are issues with dependencies.

CommentFileSizeAuthor
#106 Capture d’écran de 2018-06-01 01-15-17.png145.27 KBzenimagine
#96 Capture d’écran de 2018-05-31 13-33-24.png181.5 KBzenimagine
#95 Capture d’écran de 2018-05-31 13-13-24.png142.32 KBzenimagine
#93 Capture d’écran de 2018-05-31 12-27-48.png177.19 KBzenimagine
#93 Capture d’écran de 2018-05-31 12-28-33.png123.93 KBzenimagine
#93 Capture d’écran de 2018-05-31 12-28-43.png102.47 KBzenimagine
#93 Capture d’écran de 2018-05-31 12-28-53.png157.41 KBzenimagine
#92 Capture d’écran de 2018-05-31 12-06-39.png159.55 KBzenimagine
#82 Capture d’écran de 2018-05-30 19-58-29.png191.61 KBzenimagine
#82 Capture d’écran de 2018-05-30 19-58-29.png191.61 KBzenimagine
#81 Capture d’écran de 2018-05-30 18-49-38.png159.96 KBzenimagine
#76 Capture d’écran de 2018-05-30 15-52-45.png141.39 KBzenimagine
#76 Capture d’écran de 2018-05-30 15-52-24.png98.94 KBzenimagine
#76 Capture d’écran de 2018-05-30 15-52-10.png196.34 KBzenimagine
#75 Capture du 2018-05-30 15-39-15.png52.77 KBzenimagine
#75 Capture du 2018-05-30 15-38-57.png21.13 KBzenimagine
#75 Capture du 2018-05-30 15-38-41.png23.8 KBzenimagine
#72 Capture d’écran de 2018-05-30 12-23-48.png189.89 KBzenimagine
#70 Capture d’écran de 2018-05-30 12-04-35.png195.45 KBzenimagine
#69 Capture d’écran de 2018-05-30 11-57-37.png103.79 KBzenimagine
#68 Capture d’écran de 2018-05-30 10-17-13.png88.89 KBzenimagine
#68 Capture d’écran de 2018-05-30 10-15-10.png211.27 KBzenimagine
#65 Capture d’écran de 2018-05-30 01-43-38.png179.96 KBzenimagine
#63 Capture d’écran de 2018-05-29 16-53-47.png173.84 KBzenimagine
#62 Capture d’écran de 2018-05-29 16-04-02.png154.75 KBzenimagine
#60 Capture d’écran de 2018-05-29 15-20-34.png110.32 KBzenimagine
#60 Capture d’écran de 2018-05-29 15-20-31.png71.36 KBzenimagine
#59 Capture d’écran de 2018-05-29 15-16-58.png115.29 KBzenimagine
#54 Capture d’écran de 2018-05-29 11-18-58.png161.33 KBzenimagine
#54 Capture d’écran de 2018-05-29 11-17-00.png82.72 KBzenimagine
#51 Capture d’écran de 2018-05-29 10-46-13.png96.1 KBzenimagine
#51 Capture d’écran de 2018-05-29 10-45-55.png78.59 KBzenimagine
#51 Capture d’écran de 2018-05-29 10-45-43.png174.69 KBzenimagine
#51 Capture d’écran de 2018-05-29 10-44-45.png237.33 KBzenimagine
#51 Capture d’écran de 2018-05-29 10-44-23.png150.37 KBzenimagine
#48 Capture d’écran de 2018-05-29 03-25-27.png176.45 KBzenimagine
#45 Capture du 2018-05-29 03-03-26.png43.72 KBzenimagine
#40 Capture d’écran de 2018-05-29 00-33-20.png182.86 KBzenimagine
#38 Capture d’écran de 2018-05-28 16-56-21.png168.66 KBzenimagine
#37 Capture d’écran de 2018-05-28 16-29-30.png181.12 KBzenimagine
#36 Capture d’écran de 2018-05-28 16-15-39.png174.86 KBzenimagine
#34 composer.txt17.21 KBzenimagine
#33 Capture du 2018-05-28 13-03-08.png75.49 KBzenimagine
#31 Capture du 2018-05-28 12-04-22.png15.18 KBzenimagine
#31 Capture du 2018-05-28 12-01-50.png124.66 KBzenimagine
#30 Capture d’écran de 2018-05-28 11-22-24.png85.47 KBzenimagine
#9 Capture d’écran de 2018-05-27 05-07-26.png166.31 KBzenimagine
#8 Capture d’écran de 2018-05-27 04-43-44.png99.6 KBzenimagine
#8 Capture d’écran de 2018-05-27 04-41-08.png165.8 KBzenimagine
#6 Capture d’écran de 2018-05-27 04-25-52.png105.65 KBzenimagine
#2 Capture du 2018-05-26 21-47-17.png213.17 KBzenimagine
Capture du 2018-05-26 16-42-15.png111.7 KBzenimagine

Comments

zenimagine created an issue. See original summary.

zenimagine’s picture

StatusFileSize
new213.17 KB
jaypan’s picture

Did you add the path to nodejs in the private message configuration?
What I'm seeing is that you have successfully started nodejs, but if its not working, the scripts that connect to it are not finding it for some reason.

zenimagine’s picture

in my first post, I added a screenshot of the configuration
https://www.domaine.com
Watch the console in the inspector

jaypan’s picture

Is node.js availble at www.domaine.com?

zenimagine’s picture

StatusFileSize
new105.65 KB

no the domain is ok but it does not work

jaypan’s picture

Status: Active » Postponed (maintainer needs more info)

I'm sorry, I can't really help from here. Everything looks right, and it works for me. Please let me know if you have more information to provide.

zenimagine’s picture

Here are the only informations I have

zenimagine’s picture

StatusFileSize
new166.31 KB

when I send messages, there is nothing in the logs

jaypan’s picture

Did you install the Vendor Stream Wrapper module?

zenimagine’s picture

yes, it is installed

zenimagine’s picture

Before uninstalling it, the https://www.drupal.org/project/nodejs module has been configured like this and it works :

# nano nodejs.config.js

settings = {
  scheme: 'https',
  port: 8080,
  host: 'www.domaine.com',
  resource: '/socket.io',
  serviceKey: 'NhyYD3iP7kbES',
  backend: {
    port: 443,
    host: 'www.domaine.com',
    scheme: 'https',
    basePath: '',
    messagePath: '/nodejs/message'
  },
  debug: false,
  sslKeyPath: '',
  sslCertPath: '',
  sslCAPath: '',
  baseAuthPath: '/nodejs/',
  extensions: [],
  clientsCanWriteToChannels: false,
  clientsCanWriteToClients: false,
  transports: ['websocket', 'polling'],
  jsMinification: true,
  jsEtag: true,
  logLevel: 1
};

Does the configuration of nodeJS support the https ?

Where is the configuration in node_modules ?

It's weird that the webmaster is nothing to configure in node_modules

How is the backend managed?

Some site uses nodejs on a separate server. Would not it be advisable to configure node_modules manually with:

- serviceKey
- port
- host
- scheme

jaypan’s picture

The current module doesn't use any of that.

zenimagine’s picture

I updated #12

zenimagine’s picture

With my installation the backend uses port 443. Does your module support you?

jaypan’s picture

Nodejs is listening on port 8080.

zenimagine’s picture

This is the case of my configuration.

The node js server is on 8080

But the domain is on 443 (https)

So the module manages ports 80 and 443 for the backend ?

jaypan’s picture

No. You may have to set the node.js URL to not be https.

zenimagine’s picture

It is not possible.

I have apache header that requires secure connection.

Some browser blocks all unsecured urls

jaypan’s picture

Ok, I've found a module that handles HTTPS for nodejs. Next time I get some time to work on this I'll incorporate this module.

jaypan’s picture

Status: Postponed (maintainer needs more info) » Needs work
zenimagine’s picture

Ok thank you I will wait

zenimagine’s picture

maybe this question is related to this one ;

https://www.drupal.org/project/private_message/issues/2970962

jaypan’s picture

Assigned: Unassigned » jaypan

  • Jaypan committed 99337d4 on 8.x-1.x
    Issue #2975525 by Jaypan: I can not make Node JS work
    
jaypan’s picture

Status: Needs work » Needs review

Ok, please try again. You'll need to set up the configuration for the module. Instructions can be found here: https://www.drupal.org/docs/8/modules/private-message/nodejs-integration

jaypan’s picture

Oh, and you'll also need to run composer update, and ensure that the external library is updated, as well as both the private_message_nodejs module and the vendor_stream_wrapper module.

zenimagine’s picture

Should it use the beta 4 or the dev.
I made the update Composer, but there is no config folder.

root@vps000000:/home/www.domaine.com/public_html/vendor/jaypan/private-message-nodejs# ls
app.js composer.json node_modules package.json package-lock.json README.md

jaypan’s picture

The current version of the remote library is 0.3.0. You need to ensure that you have that.

zenimagine’s picture

How can I know the version?

- Updating drupal/vendor_stream_wrapper (1.0.0-beta2 => 1.0.0-beta3): DownloadDownloading (100%)
- Updating drupal/private_message_nodejs (1.0.0-beta3 => 1.0.0-beta4): DownloaDownloading (100%)

zenimagine’s picture

Here is what I did, but the "config" folder does not exist

jaypan’s picture

Run this:

composer require jaypan/private-message-nodejs

zenimagine’s picture

StatusFileSize
new75.49 KB

The version is in 0.2 but he does not want to update

zenimagine’s picture

StatusFileSize
new17.21 KB
jaypan’s picture

Ok, try updating this module to 8.x-1.0-beta5, then running composer update.

zenimagine’s picture

StatusFileSize
new174.86 KB

I can not update to beta 5. I'm trying to uninstall the module but I can not remove it from Composer

zenimagine’s picture

StatusFileSize
new181.12 KB

I found, you must manually delete the node_modules folder

Why compose install by defaul beta version 4 ?

zenimagine’s picture

StatusFileSize
new168.66 KB

I completely removed the module and installed it again with Composer.

He does not want to download the beta 5 and stays on the beta 4.

If I request the dev version I have the error in the screenshot.

jaypan’s picture

You probably need to run composer clearcache. Composer caches it's values for 24 hours by default I think.

zenimagine’s picture

StatusFileSize
new182.86 KB

that does not solve the problem

jaypan’s picture

Alright, I've done an update of pretty much all modules. Make sure that you follow the update instructions included with the release:

https://www.drupal.org/project/private_message/releases/8.x-2.0-beta7

zenimagine’s picture

I think the module has not been properly uninstalled. I have this error message that prevents installation. What should I do ?

Unable to install Private Message, core.entity_form_display.message.private_message_notification.default, core.entity_view_display.message.private_message_notification.default, message.template.private_message_notification already exist in active configuration.

jaypan’s picture

Re-install the message module, and that should solve the problem.

zenimagine’s picture

Can not reinstall the module. It displays #42

zenimagine’s picture

StatusFileSize
new43.72 KB
zenimagine’s picture

I found, there remained messages from the module "Message"

zenimagine’s picture

There is a problem, when the "Private Message" module is uninstalled, the message template in the "Message" module is not deleted.

zenimagine’s picture

StatusFileSize
new176.45 KB

I erased everything and checked that the files were erased. I cleaned the cace of "Composer", but it does not work ?

jaypan’s picture

Title: I can not make Node JS work » Module cannot be installed with composer due to dependency issues
Issue summary: View changes
jaypan’s picture

Ok, I think I've fixed everything with the newest version of the module. Try this:

composer clearcache
composer update

Then follow the directions here: https://www.drupal.org/docs/8/modules/private-message/nodejs-integration...

If anything goes wrong, uninstall the modules in Drupal, uninstall them in composer ensure everything is gone, then run composer require drupal/private_message_nodejs and try again.

zenimagine’s picture

Thank you, the installation worked.

But I still have errors in the console. I do not understand why.

I added screenshots of my configuration.

zenimagine’s picture

It would be necessary for other people to test an https installation, to know if it comes from the module or my site. The funny thing is that with the drupal module nodejs integration, this configuration worked.

jaypan’s picture

You need to change path/to/privateKey.key to the actual path of the private key on your server. And you need to change path/to/certificate.crt to the actual path to the certificate on your site.

The funny thing is that with the drupal module nodejs integration, this configuration worked.

That configuration was specific to the nodejs module. That module is entirely unrelated to this module, which is why a configuration for that module has no relevance to the configuration of this module.

zenimagine’s picture

Ok, the red message is gone, but I still have:

DevTools failed to parse SourceMap: https://www.domaine.com/vendor_files/socket.io.js.map

Messages are not refreshed

Can you tell me if in the screenshots my configuration is correct?

zenimagine’s picture

Is there a delay to set to activate nodejs ?

zenimagine’s picture

There are no errors in /reports/dblog

jaypan’s picture

DevTools failed to parse SourceMap: https://www.s1biose.com/vendor_files/socket.io.js.map

Have you got the Drupal node.js module enabled? Maybe it's conflicting. This module doesn't even use the file socket.io.js.map. You're going to have to do some detective work to find out what code is calling that.

zenimagine’s picture

How to be sure that the module is directly linked to the nodejs server?
There should be a message in the Drupal dashboard.

Yes, there is only the Private Message NodeJS module installed.

The warning appears only in Chrome. On Firefox there is no error, but I have to refresh the page manually to see the messages.

How can I know if the nodejs server communicates with the site?

zenimagine’s picture

StatusFileSize
new115.29 KB

OK ;-) I found. The secret does not match in the logs, when I send a message.

Yet, look at my previous screenshot, the secret is the same.

zenimagine’s picture

So the site communicates well with the nodejs server and the settings are correct.

There is a problem with the "secret"

zenimagine’s picture

It should also be added to the documentation the installation of PM2 which is essential to see the logs nodejs and maintain the connection

http://pm2.keymetrics.io/

It is very easy to install and use.

zenimagine’s picture

StatusFileSize
new154.75 KB
zenimagine’s picture

StatusFileSize
new173.84 KB

There are also two warning when I restart app.js I do not know if it concerns the module directly

jaypan’s picture

You didn't enter the full secret. There are more characters to the right.

zenimagine’s picture

StatusFileSize
new179.96 KB

I put a word in identical secret in drupal and it does not work

zenimagine’s picture

have you managed to reproduce the problem

jaypan’s picture

No. But I've added a bunch of debugging to the module. If you do an update with composer, you should be on

jaypan/private-message-nodejs: 0.3.3
drupal/private_message_nodejs: 1.0.0-beta8

Then clear your cache, go to Admin -> Configuration -> Private Message -> Settings and enable debugging for node.js. Then try the private message page. After that, you can check the Drupal logs, the browser console, and the app.js output to get more information about what is happening. See if you can find some additional information as to why it is not working for you.

zenimagine’s picture

The module does not seem to be working since the update. Pm2 logs are full of errors.

I have recreated the default.json file

There are no errors in the Drupal logs

zenimagine’s picture

StatusFileSize
new103.79 KB

I made the update to the beta 9. Here is the status of the module

zenimagine’s picture

StatusFileSize
new195.45 KB

I tested again and I still have the errors

jaypan’s picture

Those errors mean you haven't run npm install.

zenimagine’s picture

StatusFileSize
new189.89 KB

Thank you. The message has changed but I still have the error and the secret. I made a copy paste and they are identical

zenimagine’s picture

delete

jaypan’s picture

Ok, please do the following:

1) Move the [VENDOR LIBRARY]/jaypan/private-message-nodejs/config folder to [VENDOR LIBRARY]/jaypan/config. I have moved this folder out of the library, so that it doesn't have to be re-created every time the library is updated
2) Run composer clearcache;composer update
3) Run npm install in the library

I added a report on the site status page, so that may give you some additional information.

Note that I updated the instructions here: https://www.drupal.org/docs/8/modules/private-message/nodejs-integration

zenimagine’s picture

I did not understand steps 5 and 6. I uninstalled and installed the module to start over from the beginning. Can you tell me if the structure of the screenshots are correct ? Thank you

zenimagine’s picture

I tested with the configuration above, but I still have the secret problem

zenimagine’s picture

If I put a different secret, it shows on the dashboard that the server is misconfigured.

If I put an identical secret, it displays on the dashboard that the server is correctly configured.

But in the PM2 logs, it indicates that the secret does not match.

zenimagine’s picture

I have another problem. If I am authenticated, the site works. If I am anonymous, I have a blank page on the whole site with this message "The website encountered an unexpected error. Please try again later.".

See #73

jaypan’s picture

What happens if you run node app.js instead of using pm2?

jaypan’s picture

I did not understand steps 5 and 6. I uninstalled and installed the module to start over from the beginning. Can you tell me if the structure of the screenshots are correct ?

Yes, that is correct.

zenimagine’s picture

StatusFileSize
new159.96 KB

Why is there a default.json file in config and another in private-message-nodejs?

Without PM2 it's the same result.

Do you know what is causing the problem #73 (If I disable the notification block, the error disappears.) ?

zenimagine’s picture

I do not understand, when I restart app.js it marks that he received the secret "mathieu".

If I send messages, it does not work anymore.

jaypan’s picture

What version of the module are you on? And what version of the remote library?

zenimagine’s picture

The beta version 10. How to know the version of the library ?
The library is on the same server as my site.

The version of the library could be displayed on the dashboard

jaypan’s picture

You can run composer show jaypan/private-message-nodejs, and it will tell you the version number.

zenimagine’s picture

This is version 0.3.6

zenimagine’s picture

The default.json file must be in the "config" folder only? It does not have to be as in private-message-nodejs ? #81

jaypan’s picture

Both of those are correct.

zenimagine’s picture

Ok. I do not see where the problem is with the secret. I have no error message.

zenimagine’s picture

I updated to beta 11 and I have the same error message. Do you know if other users have tested the module?

jaypan’s picture

No, I think it's just you and I. But I think we're getting closer.
I just added a bunch of more debug code. I think no matter what happens, it will be easier to trace any problem. Please update, clear all caches etc, and try again. Create a private message, and visit the thread. Show me the output from that please.

zenimagine’s picture

StatusFileSize
new159.55 KB

What should I do for the update. Should I delete manually folder?

jaypan’s picture

What is the output in the JavaScript console on the page where you are seeing all those errors?

zenimagine’s picture

StatusFileSize
new142.32 KB

there is no error in the console

zenimagine’s picture

The problem is always the same. In the logs I see that he verifies and finds the secret and the second according to he verifies and no longer finds the secret.

In the dashboard, the status of "Private Message Node.js" is updated in real time.
But not the message of the thread.

jaypan’s picture

You need to turn on debugging to get the output from the console. Debugging is turned on in the configuration page.

zenimagine’s picture

Debugging is already enabled

jaypan’s picture

Enabling debugging outputs debugging information in the console. If debugging is enabled and you are not getting any output, it means you must have a cached version of the module scripts. This would explain why you are still getting errors - the scripts in the browser that interact with the Nodejs server must match the application. If your script is outdated, it will not be passing the secret correctly, and therefore you are getting errors.

You'll need to ensure that the private_message_node_js/js/*.js files are the current versions.

For example, privatemessage_node_js/js/private_message_nodejs.form.js should be this:

/**
 * @file
 * Client-side script to integrate private message with browser notifications.
 */

/*global jQuery, Drupal, drupalSettings, io, window*/
/*jslint white:true, this, browser:true*/

(function ($, Drupal, drupalSettings, io, window) {

  "use strict";

  var initialized, browserNotificationSocket, debug;

  function init() {

    // Only initialize once.
    if (!initialized) {
      initialized = true;

      debug = drupalSettings.privateMessageNodejs.debugEnabled;

      if (debug) {
        window.console.log("Initializing Node.js private message form integration");
      }

      browserNotificationSocket = io(drupalSettings.privateMessageNodejs.nodejsUrl + "/pm_browser_notification");
      if (debug) {
        window.console.log(browserNotificationSocket);
      }

      Drupal.AjaxCommands.prototype.privateMessageNodejsNotifyBrowserOfNewMessage = function (ajax, response) {

        // For jSlint compatibility.
        ajax = ajax;

        $.each(response.uids, function (index) {
          if (debug) {
            window.console.log("Emitting notification of new browser message to user: " + response.uids[index]);
          }

          browserNotificationSocket.emit("notify browser new message", response.uids[index], response.message, drupalSettings.privateMessageNodejs.nodejsSecret);
        });
      };
    }
  }

  Drupal.behaviors.privateMessageNodejsForm = {
    attach: function () {
      init();
    }
  };

}(jQuery, Drupal, drupalSettings, io, window));

Load the page in your browser, view the HTML source, copy the URL for private_message_nodejs.thread.js, and open that in the browser. You'll see the JavaScript being used. It needs to match what I just pasted above (8.x-1.0-beta12).

zenimagine’s picture

Here is what I have :

https://www.domaine.com/modules/contrib/private_message_nodejs/js/privat...

/**
 * @file
 * Client-side script to integrate private message with browser notifications.
 */

/*global jQuery, Drupal, drupalSettings, io*/
/*jslint white:true, this, browser:true*/

(function ($, Drupal, drupalSettings, io) {

  "use strict";

  var initialized, browserNotificationSocket;

  function init() {

    // Only initialize once.
    if (!initialized) {
      initialized = true;

      browserNotificationSocket = io(drupalSettings.privateMessageNodejs.nodejsUrl + "/pm_browser_notification");

      Drupal.AjaxCommands.prototype.privateMessageNodejsNotifyBrowserOfNewMessage = function (ajax, response) {

        // For jSlint compatibility.
        ajax = ajax;
        $.each(response.uids, function (index) {
          browserNotificationSocket.emit("notify browser new message", response.uids[index], response.message);
        });
      };
    }
  }

  Drupal.behaviors.privateMessageNodejsForm = {
    attach: function () {
      init();
    }
  };

}(jQuery, Drupal, drupalSettings, io));
zenimagine’s picture

I drush cr every update. Why does the file remain in memory ?

jaypan’s picture

I don't know. But that's not the right file.

zenimagine’s picture

I never had a problem with other libraries.

Do you have a command to update the cache ?

jaypan’s picture

I don't know. This is a problem with your system, not with the module. You'll need to figure out why your system is caching the script and not using the new script that comes with the most recent version of the module. I would suggest uninstall removing the private_message_nodejs module from the system with composer. Confirm that the module does not exist anymore. Then clear your cache, and re-install the module with composer.

You can clear the cache with drush cr.

zenimagine’s picture

Thanks it works now ;-)
I erased the browser cache.

zenimagine’s picture

StatusFileSize
new145.27 KB
jaypan’s picture

Status: Needs review » Fixed

Great! I'm glad we got it worked out. It was a bit of a pain, with a lot of work, but actually it has made the module much stronger and much easier to debug now through trying to fix this, so it's a good result.

Thanks for sticking through it with me.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.