Strange behaviour of Mean.io on Azure VM‏

270 views Asked by At

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?

1

There are 1 answers

0
Luca On BEST ANSWER

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.