Strange behaviour of Mean.io on Azure VM‏ - node.js

I created an Azure virtual machine with Ubuntu 14.04 LTS OS.
I installed a mean.io application version 0.3.3, on this virtual machine, with nginx that proxy the requests in the http port 3000 over the port 80.
I opened one endpoint in azure portal, for the TCP protocol on private port 3000 and public port 80.
I installed the latest version of node on Azure VM.
The database (mongoDB) is hosted on compose.io.
With pm2 (https://www.npmjs.org/package/pm2) I created a daemon that run the application.
All apparently works fine: the cpu was with no load and the memory was empty (only 100MB).
But after a period, node.js cannot process the request.
I have tried to do a 'curl' in localhost 3000 but i dont have any response.
The problem persists only in Azure VM: I tried the same application, with the same configuration, on my dev machine (ubuntu 14.04 desktop), and on Digital Ocean (another distro of ubuntu 14.04 server) and all works fine without problem.
Can you help me to find the problem?

I have tried to dockerize all infrasctructure, in the same machine (a CoreOS vm on azure):
1 container with mean app,
1 container with MongoDB,
the problem still persisted!!!
finally, i have found the solution: keep the connection to MongoDB alive.
i have modified the server.js file from the mean app in this mode:
var options = {
server: {
socketOptions: { keepAlive: 1 }
}
};
var db = mongoose.connect(config.db, options);
In this mode the connection still alive and the problem was solved.

Related

Access to node server and react app hosted on vm via internet

I'm trying some stuff with vms (vmware) and nodejs.
I setup 2 vms runing ubuntu 20.04.5 LTS with static ips let say : 192.168.10.3 and 10.4 each accessible via ssh over internet with my public ip :
ssh -p 103 admin#\<public-ip\>
ssh -p 104 admin#\<public-ip\>
I opened those ports(103 and 104) on windows firewall and forwarded them on the router, everything is fine till now.
In one vm (10.4) i installed the node server running on port 3000 ( which i can access from windows in : 192.168.10.4:3000) and a react app (it can be anything using a different port) on 3001.
How can i access the node server or/and the react app using my public ip ?
i tried on the browser : public-ip:104 but firefox blocked it "This address uses an unusual network port for web browsing. As a security measure, Firefox dropped the request."
public-ip:3000 is not working either

How to deploy dotnet core application on Ubuntu server with Nginx server?

I have a dotnet core application built on dotnet core 3.1 and when I tried to deploy the same in ubuntu 18.04 server by following the steps given in this doc but not able to access the app on port 80 (accessing through public IP)
Here is the Nginx updated configuration
and dotnet application is running with port 5000 and 5001 (for now I didn't configure service to the same)
Getting the following error when accessing through the browsers ( public IP)
I'm missing any configurations?
The problem was IISexpress port access issue.
By default, the IISexpress does not allow the external network to access the port and this access needs an explicit configuration.
If you are facing the same problem, you can find the code snippet and other details here.
Accessing IISExpress for an asp.net core API via IP

Docker Xdebug LAN / Public Dev server

I want to get Xdebug running in a semi secure manner over LAN in the office. Our current setup is as follows:
Local server on LAN network under 192.168.1.1 with Ubuntu Server 16
Multiple instances of docker with PHP / Apache running on Ubuntu server
Jwilder nginx proxy for forwarding all requests to individual docker containers
https://github.com/jwilder/nginx-proxy
Files are directly edited over an internal SMB share where Windows hosts connect to the Linux share. These are the hosts running PhpStorm.
The machine is exposed to the world using port 80. LAN has access to all ports.
I'm at a bit of a loss how to properly setup Xdebug using PhpStorm where only those within our LAN can trigger the debugger and debug from map files from a Linux host on Windows.
A DBGp proxy would be the answer here.
It limits all debugging connections from the web server to a single host inside the LAN.
It allows you to perform multi-user debugging with the help of IDE keys.
JFYI, in Xdebug, it's the web server that initiates a TCP connection to the client (the DBGp proxy in this case), so some Docker networking magic is required here.

Elasticsearch : connect to a remote server via. SSH (Node JS)

I'm currently using Node's [elasticsearch][1] package. Until now, I connected to the ES instance in the following way.
let esClient = new elasticsearch.Client({
host: '127.0.0.1:9200',
log: 'trace'
});
Now, I've installed ES on a remote Amazon EC2 Linux server by tunneling through SSH using a key file.
I've done the basic ES installation and setup on that server. Tested it as well, and it runs properly.
I've now deployed my Node project on a Server X (EC2 - Ubuntu server).
And Elasticsearch is on Server Y(EC2 - Amazon Linux server).
Apart from specifying the IP in the host parameter what else do I need to connect to ES running on Server Y from Server X?
You have to make sure you have the port (9200) open in Amazon's Security Group settings.

Angular 4 Failed to load resource: net::ERR_CONNECTION_REFUSED

I guess I will start at the start of my application.
I am making a full mean-stack application and I want it to run in docker. To use docker I am using a virtualbox with Ubuntu. When I run my docker-compose, everything is working on localhost:4200. Now I want to open my application on my host machine (Windows 7).
When I go to my application via (ip addres should be kept secret, right?) xxx.xxx.xx.xxx:4200/login the page looks fine, but I get these errors:
I am using Angular cli 1.4.1 with node 8.4.0
Why am I getting these errors and how do I fix them?
My docker-compose
Your server which is listening on port 4200 is listening on your xxx.xxx.xxx.xxx interface (not necessary to hide lan IP, but nevermind...).
Your angular application is running on your host system. the localhost is the localhost of your host system, not the guest. so you have two solutions:
changing your urls inside the angular application to point to xxx.xxx.xxx.xxx:4200 instead of localhost:4200.
Forwarding your 4200 port from your host to your guest system using virtual box :
shutdown guest.
select guest and click on settings
go to the network tab.
click on "advanced"
then select "ports redirections" and bind your host 127.0.0.1:4200 to your guest's 4200 port

Resources