Outbound SSL connection from Node - node.js

I am trying to connect from Node to a server that is using SSL. The connection works when I connect to a test server, but not the live server I need to connect to.
Does anyone know if Node requires some sort of configuration to support outbound connections?
Thanks

I upgraded node to 0.8 and this started working.

Related

WebSocket connection to 'ws://127.0.0.1/ws' failed when run web app

I have a nodejs web app with websocket , when i run on localhost it's not problem but when i run on public host (have SSL,domain name...) i get error : WebSocket connection to 'ws://127.0.0.1/ws' failed .
Question here is, where are you trying to connect from
Client OR Server
The error message would indicate you are trying to connect to a localhost, so if you are getting this message back from the client side, then its because your connecting to a non-reachable WS instance. Also, if you WS host is https, you would use WSS protocol vs just WS
As mentioned, without seeing the code its hard to tell
You need to setup your server environment, is your web-server (Apache, nginx) correctly pass requests from world to your node app?..
Is your server firewall pass WS connections?..
IMHO you need a consultation from your provider DevOp's support team.
You are using the following according to your statement:
ws://127.0.0.1/ws
From what I have read in the various ws api's while researching my own websocket issues I believe you would need to make the following change:
wss://127.0.0.1/ws
as wss is used for SSL connections.

Unable to connect to node.js server using HTTPS

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?

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.

Google Cloud: HTTP Connection refused after VM restart

We have a node server hosted on Google Cloud.
It is handled by a VM instance on GCE and has open ports for HTTP/HTTPS.
It worked fine until I rebooted the VM instance...
If I try to connect to my API it now returns ERR: CONNECTION REFUSED
I'm pretty sure this is not happening because of the node server as logs are clearly showing the node server is not being accessed at all when connecting to it's IP or URL.
I can still SSH to the VM...
BTW: iptables empty and firewall rules double checked
Does someone know what could be the problem ?
I'd love some help... Thanks ! :D
Ok I'm going to answer my own question so it can help anyone facing the same issue...
For me it was my Apache server not being automatically restarted... As simple as that yeah ahah!
If you're not using Apache check any routes or so in iptables.
My node server was listening on 8080 port but HTTP and HTTPS requests are respectively 80 and 443...

Allow WebSockets in Google Compute Engine (GCE)

I'm using Compute Engine (GCE) to run my socket server with Socket.IO (Node.js)
It's only working with polling. When I try to use a web client I receive this error code:
WebSocket connection to 'ws://myapp-socket.appspot.com/socket.io/?EIO=3&transport=websocket&sid=Tt4uNFR2fU82zsCIAADo' failed: Unexpected response code: 400
What am I doing wrong? Is it GCE configuration problem?
You cannot use the myapp-socket.appspot.com domain in your script when using WebSockets. Instead, you will need to use the external ip of the GCE instance and connect directly to that, opening any firewall ports you may be using.
I believe traffic going to the appspot.com domain is also going through frontend webservers and socket.io needs a direct connection to the server.
The Virtual Machines in Google Compute Engine have port 80 for http and port 443 for https. Using these ports for web-sockets solved the issue.

Resources