Node server delay - node.js

I have node js server running a script through pm2 daemon.
sometimes the server cannot be connected to on the first try, a second try and the server can be connected to perfectly.
I have now moved from http to http2 server base.
any suggestions.

Related

Node express server always shuts down

I have a angular app running in a universal express server.
I start the server with
nohup node server.js &
exit
The server runs fine, but after a while 5 to 30 Minutes it stops with nothing in the nohup logs.
Same happens with forever or pm2, after a while the server is gone without any hint for the error.
Any ideas how to debug, this is on a hosting environment.
Thanks

Node express js server returning HTTP 426 upgrade required

I have created sample express js hello world application listening on port 3000.
When application accessed using URL http//localhost:3000/ application run properly.
But if accessed using machine name , http://fullmachinename:3000/ , getting HTTP 426 upgrade required response
Port is being used or blocked, switch to another port and try again.

Difficulties connecting to socket.io server with Ionic

An overview of my setup:
A socket.io/node server is being hosted/ran on a computer in my local network.
An Ionic app is attempting to connect to the socket.io/node server to send/receive messages.
If I run the app in the browser with 'ionic serve', I am able to connect to the socket.io/node server successfully.
If I run the app in the emulator or on my device, I am only able to connect to the socket.io/node server if I add the -l (livereload) flag (ionic run android -l).
Originally, I hosted the node server on a heroku instance. I had no troubles connecting with this setup from browser, phone, or emulator. I had to switch to running the node server on a local computer so I have access to a local database.
Any ideas what is going on?
I fixed it by adding 'http://' to the beginning of the connection string.
Not sure why Ionic's livereload enabled me to connect without the 'http'

Accessing Node Proxy Server from a locally hosted file

I'm trying to access a node proxy server running on my local machine from somewhere else(specified later). I've tried setting proxy listening domain to 0.0.0.0 with with port 8888. The file that will send request to the proxy server is hosted using a simpleHttpServer at 127.0.0.1 with port 4444 on another computer. In this file, I'm sending the request to http://my_local_ip:8888 (I'm assuming this is where the Node Proxy lives on my computer). However, I'm get connection timeout for some reason. Does anyone see problems with this approach?

NodeJS process disconnects on SSH session logout

I am doing SSH on the server, which is Ubuntu 14.04 server. I tried various things to keep the Node server running. But as soon as I type exit and disconnect the server from my Ubuntu Desktop the Node server is also disconnected.
Though it is running on the server. When I SSH into the server I can access it.
I have tried these :
nohup node server.js &
nohup node server.js > /dev/null 2> error.log < /dev/null &
sudo nohup supervisor server.js &
forever start server.js
Also I tried using tmux and screen. Its the same problem with all of these. As soon as I disconnect the SSH the node server is not available. But when I just login to the server, it is available again.
What am I missing?
Though it is running on the server
seems to contradict
As soon I disconnect the ssh, it terminates
Are you doing anything special with your ssh session? ( like forwarding server port to a client ) How do you check if server is running?
Possible reasons:
1) You test using server's localhost when on server and server IP from client: check you are binding your server to "0.0.0.0" address and not 127.0.0.1
2) You have some kind of port forwarding and connect to server vi client localhost:forvarded_port -> ssh -> server localhost:remote forward side port. - Checj you are listening on 0.0.0.0, that server IP is not blocked by firewall and try to access it via direct ip/port

Resources