Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run node on another server #2

Open
nesjett opened this issue Jan 9, 2017 · 15 comments
Open

Run node on another server #2

nesjett opened this issue Jan 9, 2017 · 15 comments

Comments

@nesjett
Copy link

nesjett commented Jan 9, 2017

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,

  • Nes
@lonalore
Copy link
Owner

lonalore commented Jan 9, 2017

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
Copy link
Author

nesjett commented Feb 6, 2017

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

  • Nes

@lonalore
Copy link
Owner

lonalore commented Feb 6, 2017

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

@nesjett
Copy link
Author

nesjett commented Feb 6, 2017

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

@nesjett
Copy link
Author

nesjett commented Feb 6, 2017

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
Copy link
Owner

lonalore commented Feb 7, 2017

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

@nesjett
Copy link
Author

nesjett commented Feb 9, 2017

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
Copy link
Owner

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
Copy link
Author

nesjett commented Feb 10, 2017

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
Copy link
Author

nesjett commented Feb 10, 2017

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
Copy link
Owner

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

@nesjett
Copy link
Author

nesjett commented Feb 11, 2017

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
Copy link
Owner

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

@lonalore
Copy link
Owner

lonalore commented Feb 12, 2017

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
Copy link
Author

nesjett commented Feb 12, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants