Unable to connect to node.js server using HTTPS - node.js

I'm using Node.js 10.0.0 and trying create a node server that uses HTTPS.
I followed this documentation to create the needed certs and keys etc.
I can connect from localhost to the node server just fine. However, if a Windows machine on the same network as the device running the node server tries to connect to the server using HTTPS the browser says "Trying to establish a secure connection" and times out and the page fails to load.
What am I doing wrong? I'm new to node and HTTPS etc. What can I do to debug this problem?

Related

beginner webrtc/nodejs issue connecting remote clients

I'm trying to develop a web application in nodejs. I'm using an npm package called "simple-peer" but i don't think this issue is related to that. I was able to use this package and get it working when integrating it with a laravel application using an apache server as the back end. I could access the host machine through it's IP:PORT on the network and connect a separate client to the host successfully with a peer-to-peer connection. However, I'm now trying to develop this specifically in node without an apache back end. I have my express server up and running on port 3000, I can access the index page from a remote client on the same network through IP:3000. But when I try to connect through webrtc, I get a "Connection failed" error. If I connect two different browser instances on the same localhost device, the connection succeeds.
For reference: i'm just using the copy/pasted code from this usage demo. I have the "simplepeer.min.js" included and referenced in the correct directory.
So my main questions are: is there a setting or some webRTC protocol that could be blocking the remote clients from connecting? What would I need to change to meet this requirement? Why would it work in a laravel/webpack app with apache and not with express?
If your remote clients can not get icecandidates, you need TURN server.
When WebRTC Peer behind NAT, firewall or using Cellular Network(like smartphone), P2P Connection will fail.
At that time, for fallback, TURN server will work as a relay server.
I recommend coTURN.
Here is an simple implementation of simple-peer with nodejs backend for multi-user video/audio chat. You can find the client code in /public/js/main.js. Github Project and the Demo.
And just like #JinhoJang said. You do need a turn server to pass the information. Here is a list of public stun/turn servers.

Local server http communication and angular browser rendering

I think I'm doing something completely the wrong way.
I have an Nodejs server running that read in a DB and serve with express some data via http locally (it has to only be accessed locally). It sends the data on localhost on some port (8080 for example). Then I have an angular app on the server that get these datas from an http request on localhost:8080 and display them. The angular app runs locally on localhost:4200.
I was building the entire stuff on my computer and that was working perfectly (I have no problem with CORS). Then I deployed it on a server, and I accessed it via ssh port forwarding. Basically I forward localhost:4200 on the server via ssh on my local computer on localhost:8090.
And my problem is that, when loading and executing the angular app in my browser via port redirection, it's doing a get request to localhost:8080. So it's trying to communicate with the localhost it's running on, which is the client itself.
If you understood my spaghetti situation, there is actually a dirty solution : redirect localhost:8080 on the server to localhost:8080 on the client.
Is there any way to do the get request server side and not in the client's browser so that localhost correspond to the server? Is there a better way to do what I'm trying to do?
I can sum up by : How can you access another local service on localhost on the server with angular app since it executes in the client browser and localhost will refer to client localhost.
Try to use any web server (such as nginx or apache2 or etc.) in your server and make use of proxy and reverse proxy with your node application, it will work
angular2-router-and-express-integration

How to connect to a Node.js WebSocket Server from a port forwarded server?

I am trying out a chat program using HTML5 app and Node.js WebSocket on my computer, following the video https://youtu.be/hv9KdklXZqE.
The Node.js WebSocket listens to port 5555 and is at C:\xampp\htdocs\TestWebSocketServer. On the client side, we have a HTML5 website in XAMPP server also on my computer at C:\xampp\htdocs\TestWebsocket_client
We would like to send some messages from our client to the WebSocket server on my computer. My computer is in a LAN network behind our Main Server that is accessible online. (Let's assume it is named "http://exampleSite.com".)
To do this, we did a fixed IP address on my computer and did a port forwarding in the Main Server which points to my computer. We chose port forwarding port 5555.
To ensure my computer is accessible to outsiders on the Internet, we set the Firewall to allow network communication both public and private for apps such as node.exe and Evented I/O for V8 Javascript.
And to test that the computer is globally accessible, we tried access "http://exampleSite.com:5555/". The result is we can access the index.html and other files that resides in XAMPP's htdocs directory in my computer correctly.
To test WebSocket, we run our Node.js WebSocket server. Then we open our http://exampleSite.com:5555/TestWebsocket_client/ , our HTML5 site runs correctly, but then when we try to connect to the Node.js WebSocket, we got the error:
WebSocket connection to 'ws://exampleSite.com:5555/' failed: Error
during WebSocket handshake: Unexpected response code: 302
Codes
For the client side code, it is actually Construct 2 exported HTML5. We are using exactly 3 lines of same codes at https://youtu.be/hv9KdklXZqE?t=6m45s
For the server side code, the same code is also from the video above at https://youtu.be/hv9KdklXZqE?t=7m7s
We have verified in our localhost environment just like in the video that the client C2 side can connect to our Node.js server without any problem.
How to connect to the Node.js WebSocket Server in this case?

Error Connecting Node-Ubuntu Droplet to Meteor Galaxy Server Over DDP

I am trying to connect a node server hosted on a Digital Ocean-Ubuntu machine to my Meteor server hosted on Galaxy over DDP.
This node server handles some of the CPU heavy server tasks, but the jobs that it does the work for are created on my Meteor server. So, the two servers must communicate over DDP.
This works fine when I have my node server run on my local machine and connect to my Galaxy-hosted Meteor server. However, once I move my node server to DO and try to run the same code, I get a connection timeout error.
Any idea why this would happen when trying to connect from DO?

Create websocket connection between another server and a client

I'm building a desktop application where clients will interface with the server through the browser, but will also connect to eachother using a local node.js server. This means that every client has a local node.js server running.
I want to allow users to connect to the central webserver with the browser, and then initialize direct connections to other client's local node.js server. Is there a production ready way to expose a local node.js server to the outside world, or otherwise proxy the connection between the two?
Right now, my solution is to use localtunnel to expose the server, and then make a connection. As far as I understand, this is not recommended, and I'm looking for something better.

Resources