Server not responding after sometimes - node.js

I am using node.js for backend for android apps and pm2 to for run it continuously, AWS EC2 server.
he problem that I am facing after sometimes when I hit API using android app sever doesn't send any response for a while and after sometime it works fine or when I turn on/off my flight mode it also responding. I cant figure out how to resolve this issue???
sorry for my bad English.
I want to resolve my problem any how.

Related

Remote Server Terminal of for specific Applications

I have a server and i want my colleague to access only the application terminal of a specific application or console log the errors or anything he wants to log. I have used console.re, a remote console client, but i couldnot access it from my own machine; It somehow works on brower of the client but not elsewhere. I want something that could solve this problem. BTW i use node js application if there is any package that could resolve this i would be really thankful.
Thank you,

How to deploy a React + Express app on a local network?

This is my first post here, let me know if I do it wrong. I would like to start by mentioning that I'm kind of a beginner developer. I've had a bunch of classes, but it's also my first time working on something of my own, from beginning to end (emphasis on "end").
I'm working on a relatively simple app, for user management (CRUD, with different levels of authorizations) and shop management. I was given the choice of the tools, framework, language, etc, to use, with the only constraints that 1/ the main device to use it will be a tablet most of the times 2/ nothing should be hosted online. I wanted to get more familiar with Javascript so I went with creating a React app (front) with Express Nodejs (back) and a MySQL database I access via Sequelize.
Development is going fine (for the most part thanks to many great posts here on SO), but I just got hit by the reality that I have never tried to build the app and see if it runs the way I intend. And I do not know how to do it. I should have researched that earlier.
So far, in development I always tested everything on PC and phone by running npm start (front end) and node server.js (back end), and the client runs in a browser (when using a phone I access the IP adress and port, like 192.168.x.x:3000). Backend listens to the 8080 port no prob, access to the MySQL database works as intended thanks to Sequelize. Frontend listens to port 3000 to display the user interface on the browser, and React makes it easy to develop features in front, and quickly troubleshoot them. Everything works fine, and as expected, anyone in the same network (and with a web browser) can access and use the app that way.
This is the behavior I want to replicate with a production build : having a computer host the build, and run the "server" so that the app is available to any device in the local network. So I guess I need to somehow make my build in a way to make it possible to turn on and off the "server" at will, maybe via a .exe ? Or turn it on at the same time as the computer ?
I know I should have researched that earlier and not doing so was a mistake. All I know is I'll have to use npm run build, to get the build folder, but I don't know what to do from there. Could you help me figure it out ? Among many things I'm not sure of, is whether or not the host computer (not mine) needs to have node.js installed ? Does it also have to have MySQL installed ? Do I make a single build that incorporates the backend and the frontend, or do I build both separately ? If so, how ?
Let me know if you need to see part of the code. Thanks in advance and have a great day.
EDIT : App was created using create react app
There are options to deploy on cloud like Cloud Servers. But I think you're looking for hosting the application on the local machine. You need to create a service, bundle the application and serve whenever you want.
Following link might be helpful
https://www.section.io/engineering-education/compile-your-nodejs-application-into-a-exe-file/

Read stdin from a NodeJS app deployed to Heroku?

I'm working on a NodeJS server application (NodeJS/Express/Socket.io). It also uses readline to provide a debug console that grabs commands from stdin. It works fine now, but I suddenly realized that I've never made a console application on Heroku before. I'm nowhere near ready for this app to be deployed yet, so I just tried searching for information about this, but came up blank. Does Heroku offer a way to provide stdin input to a NodeJS server application running on one of its dynos? How does that work? Is there any change I'd need to make in the code when it's time to deploy?

Debug node.js web application that has been launched via a Gulp task

I have a web application that is written in node.js and gets started using a gulp command. When the application first starts, before the server is running, debug points may be hit in WebStorm (or in any IDE or command line tool). However, after the server is running and I go to the interface in my localhost I can no longer hit debug points inside the application. This is not being caused by client side code as the debug points are in server code.
I have read the answers that involve using the node-inspector and that has not solved my problem because of configuration files that are not getting read when starting the debugger in node inspector.
I'm a bit surprised that there is so little on here about this issue. Is it not a normal problem that other developers face? Thanks in advance for the help.
My workaround for this may not be sufficient for every case. I was modifying JavaScript files and didn't actually need the configuration files, after loading, to be able to test my changes. I did the following:
Wrote a line in my app.js file that set the variables I needed. (these would have been tasks ran in Gulp)
I then started the app as a Node.js app and was able to debug it as normal.
If any of my views had been updated, or anything else that was being managed by Gulp, then I could have simply stopped the server, started it again via the Gulp command, and then stopped again and restarted as a Node.js app.
This did not solve the issue in my OP but it was a good enough workaround to get debug points in the JavaScript.

Node.js unresponsive until key press on console

I have a Node.js app, that runs on a Windows Server 2008. I'm facing a weird problem here.
My app does more than one async tasks. Sending data to socket.io, MySQL, HTTP connections, TCP connections etc.
My Node app becomes unresponsive especially on the socket.io end, and only starts responding back again after any key press on the console. Is this a known issue? Any bypasses around such a behavior?
Note: I am using console.log heavily to keep track of the current operation and errors in process.
I did a bit of a background check and came to the following conclusions.
The Powershell console on Windows Server 2008 goes on a 'pause' mode when clicked on it. It is released again if you click elsewhere.
http://www.vistax64.com/powershell/112032-script-pauses-when-you-click-powershell-text-window.html
If you notice, console.log is async. But console.warn and console.error are blocking. These are not async.
The console pause might block some/most part of the Node.js operations. Esp. as Socket.io at default debugging level will report with more than just console.log.
Solutions that other people have suggested didn't work for me, but using Cmder to start the script solved it. Definitely appears to be a console application problem, rather than a node.js problem.
I faced the same problem in a Windows Machine with my Node.js server running on PowerShell.
I solved it disabling Quick Edit Mode and Insert options in the Properties panel of PowerShell. It seems like pause the process when you click on the terminal with those two options enabled.
Hope this helps you, bro.

Resources