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

How can I make this work for https secured server? #143

Closed
davidchristine88 opened this issue Nov 15, 2017 · 17 comments · Fixed by #170
Closed

How can I make this work for https secured server? #143

davidchristine88 opened this issue Nov 15, 2017 · 17 comments · Fixed by #170
Labels

Comments

@davidchristine88
Copy link

I tested it using http is seems ok, then I switched to https server and is having WebSocket connection to 'wss://localhost:9856/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

Is there some special steps I need for https server? Any tested example? Thanks.

@alallier
Copy link
Owner

alallier commented Nov 15, 2017

For a quick glance we might have to implement a proxy to handle the https. This needs to be looked at a little further.

https://github.com/TooTallNate/node-https-proxy-agent

@alallier alallier added the bug label Nov 15, 2017
@AckerApple
Copy link

AckerApple commented Nov 15, 2017

IF you are running a NodeJs https server already, which supports middleware:

  • You just need to use reload in a middleware fashion to attach it to your existing server.
  • I dont think this reload package offers middleware.
  • I forked this code long ago and offer middleware in my package ack-reload

IF you are trying to run reload as the HTTPS server

  • For now, I suggest you write the basic https server and have reload middleware into it like so:
var reload = require('ack-reload')
var midware = reload.middleware( './pathToServe' )
 
require('https')
.createServer(httpsOptions, function(req,res){
  midware(req,res)//reload will do its thing here. I mean ack-reload
})
.listen(443,function(err){
  //the server is alive at this point

  if(err){
    console.log(err)
  }else{
    console.log('server started')
  }
})

The above code works only for ack-reload and the above code does not have a unit test and is only an attempt to illustrate the mentioned concepts.

Good luck!

@AckerApple
Copy link

If a concern exists of the wss protocol being secured, it's secured by nature regradless as answered here: https://stackoverflow.com/questions/26791107/wss-on-http-vs-wss-on-https

So its just a matter of supplying the httpsOptions and doing require('https') instead of require('http')

@davidchristine88
Copy link
Author

Thanks for the info. I was just attempting to integrate this reload module to an existing app that requires https in production and found out it won't work. It tested ok in development http mode.

@AckerApple
Copy link

AckerApple commented Nov 15, 2017

Try ack-reload with the middleware. It's a fork of this package and works quite the same (see benefits-of-ack-reload-over-original-reload-package)

Since you already have an https NodeJs app, all you need to do is give ack-reload's middleware the request/response objects and the rest will work like magic.

Let me know

Another middleware example on ack-reload package: https://www.npmjs.com/package/ack-reload#express-example

@alallier
Copy link
Owner

Reload used to attach the WebSocket server to the node server but it no longer does that. It creates it's own server to run on it's own port so it doesn't hijack the node server, hence why we might need to consider a proxy or some other solution.

Also, @AckerApple this is your final warning please stop using these issues to advertise your fork. If you have something to contribute on possible solutions, ideas, etc. that help our project we welcome them. But do no use these threads to continuously inhibit our productivity with fork advertising, project/user bashing, and solutions that only involve your fork. Feel free to reach out to these users via other methods to discuss your fork.

@AckerApple
Copy link

You got it. I'm outty 500 and unsubscribed. Good luck and fare well

@alallier
Copy link
Owner

alallier commented Jan 4, 2018

#147 (comment)

@alallier alallier mentioned this issue Dec 26, 2018
@meszaros-lajos-gyorgy
Copy link

Hi! Do you have a planned date for releasing the next version? Not being able to use reload on https projects is a real bummer. Is there a temporary fix we can use to bypass this issue? I've tried loading reload.js through http, but it checks window.location.protocol for https instead of document.currentScript.

@alallier
Copy link
Owner

alallier commented Jan 7, 2019

@meszaros-lajos-gyorgy the next version is going to be released really soon. You're welcome to give it a try and provide any issues/feedback.

@meszaros-lajos-gyorgy
Copy link

Do you have a snapshot version of 3.0.0 released to npm, or should I build it locally from the github repo?

@alallier
Copy link
Owner

alallier commented Jan 8, 2019

You should build it locally from GitHub

@meszaros-lajos-gyorgy
Copy link

I'm gonna go with npm i git://github.com/alallier/reload.git#3.0.0 --save-dev and do a few tests on it.

@meszaros-lajos-gyorgy
Copy link

I have the same error: WebSocket connection to 'wss://localhost:9856/' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR. Do I need to make additional configuration to make reloadjs work on https?

@alallier
Copy link
Owner

alallier commented Jan 8, 2019

Yes you do, consult the README on that branch

@meszaros-lajos-gyorgy
Copy link

Works like a charm!

@alallier
Copy link
Owner

alallier commented Jan 8, 2019

Perfect! I appreciate the feedback!!

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

Successfully merging a pull request may close this issue.

4 participants