lonalore / nodejs

e107 (v2) plugin - It provides an API that other plugins can use to add realtime capabilities to e107 (v2), specifically enabling pushing updates to open connected clients.
GNU General Public License v2.0
2 stars 4 forks source link

Run node on another server #2

Open nesjett opened 7 years ago

nesjett commented 7 years ago

Hello, I find your plugin really interesting, but I have one question. ¿Can you run e107 on a traditional web server (apache or nginx) and run the node.js on another server?

This is because some shared hosting doesnt allow incoming sockets to be open, that means socket.io would not work.

I´m not sure if your plugins allows that, but I think that would be possible.

Thank you for your time,

lonalore commented 7 years ago

Hello, yes, of course! If you don't have NodeJS support on your hosting, you can run your Node server for example on Openshift or Heroku.

nesjett commented 7 years ago

Hello lonalore, thank you for your time.

I´m getting some issues with your plugin, not sure why, It works on localhost (xampp) but it breaks the page when on shared hosting, showing a white page due to e_header and e_module files. Any clue on what could be happening? (tested with latest git version and older versions too)

About the heroku setup, I alredy did it, but I cant test it due to the issue with the plugin on the e107 site. Is there another way of testing it? (I mean to broadcast a message in another way)

Thanks

lonalore commented 7 years ago

Hi! Please enable debug mode, and check your error.log for more details.

nesjett commented 7 years ago

Thanks for the tip, here we go: Parse error: syntax error, unexpected '{' in .../e107_plugins/nodejs/nodejs.main.php on line 655

nesjett commented 7 years ago

Forget it, PHP server version was actually 5.4, try/catch/finally was included in 5.5. I´ve not imagined that server was outdated.

Ill give you feedback when I get the plugin to work.

Thank you again

lonalore commented 7 years ago

Ahh thank you! I'll update the dependecy list of the plugin soon.

nesjett commented 7 years ago

Sorry to bother you again, but I can´t get it to work (exactly to connect with my node.js server)

I´m not used to node so I´m not sure how works the config files, I mean that there are 2, the .config and the server.js, both of them contains similar information related to the configuration so I´m not sure if I´m doing it the right way.

The heroku server seems to work (because logs says that) but when I try to send a broadcast from my e107 admin control panel it doesnt do nothink, logs doesnt seem to receive any connection either.

Can you explain me which file should I edit? or how to test if the website is actually sending the request in the right way, to the right url/port?

Thanks

lonalore commented 7 years ago

Hi,

Here is my NodeJS config for e107hungary.org:

Admin UI: kepernyokep_2017-02-10_11-03-41

nodejs.config.js file: kepernyokep_2017-02-10_11-03-31

NodeJS is running on the same VPS, where the website is. I've never hosted NodeJS on Heroku, but Openshift. If I remember well, I had to play with Openshift's global, environment variables.

scheme: 'http',
port: process.env.OPENSHIFT_NODEJS_PORT || 8080,
host: process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1",
resource: '/socket.io',
serviceKey: '',
backend: {
    port: 80,
    host: 'yourdomain.com',
    scheme: 'http',
    basePath: '', // If your e107 is in a subfolder, use this syntax: /my_folder
    messagePath: '/e107_plugins/nodejs/nodejs.php'
},

And on Openshift, the NodeJS endpoint can be reached on port 80, so I could set "80" for "NodeJS Server Port" on the Admin UI.

I think Heroku works similar than Openshift.

nesjett commented 7 years ago

Thank you for your detailed reply, visiting your site confirmed that my website isnt performing the ajax call to start the websockets connection.

I´ll try to find the issue and tell you if its plugin related or someting wrong with my site (but its a clean installation)

nesjett commented 7 years ago

Solved, e107 haven´t searched for new e_ files on plugin installation... That was an automatic proccess in the past I think

I´m almost near to get it working, but get a final error, when I left the nodejs server host empty, it executes the server, but doesnt seems to get connections to work (invalid namespace error) but when I add the app host (xxxxx.heroku.com) I get the following error, crashing the app:

screenshot_62

Do you have any clue on this? Sorry for the inconveniences..

lonalore commented 7 years ago

Could you please share your config with me? You can send details on Gitter, in a private message.

nesjett commented 7 years ago

I´m getting the same issue on openshift, if I add the host, it crashes the app, but in this case, if I let the host empty, ajax calls doesnt reach the endpoint (openshift returns a 503 service unavailable)..

Maybe some kind of issue with latest nodejs versions?

lonalore commented 7 years ago

Okay, I will try to setup the plugin on Openshift today.

lonalore commented 7 years ago

Everything went fine! I created a small tutorial video, I hope it will help! ;-) How to install and config NodeJS plugin on e107 v2 (NodeJS hosted on Openshift)

I use https on my website, so I used port 443 instead of 80. If you don't use SSL on your website, jus use port 80.

nesjett commented 7 years ago

Thank you so much for the vid, but I still cant get it to work. I´m using the next gen openshift version, and seems that I cant make it to work, Ill try another service because everything seems the same as you show in your video.

Plus I found a big security issue, Ill send it to you on private at gitter