Server is running but getting "could not proxy request from localhost to localhost" error on react - node.js

So I am in a very weird situation.
I have a react app with node js backend which was working just fine a couple of days ago.
I don't know what happened but the client stopped connecting to the server by returning a message "Proxy error: Could not proxy request".
I then tried testing just the server side and sent a few different requests via postman. I had these requests saved in my postman as I used them a thousand times before and they all worked fine. But then postman comes back with "Client sent an HTTP request to an HTTPS server".
I checked hundred times my server is running, I can see in the console "Listening on port 5001...".
Furthermore, I tried running the app on another machine, my laptop, and it works all good.
I have spent two days on this issue and I have no clue what's going on.
Things I tried:
all proxy related suggestions on stackoverflow such as changing localhost to 127.0.0.1 or adding a "/", etc.
deleted node modules, and reinstalled
deleted the repo and recloned
tried running on node instead of nodemon
I have no clue what happened to my desktop machine that it literally stopped connecting to the server.
I don't know if you'd need to see any piece of code but I am happy to share anything you need, I just don't know what would help to show.

Related

Session checked out from process (Node JS Log error on Plesk panel)

the Website developed with React, Node and mongoDB is deployed using Plesk panel.
Server seems to work fine. and suddenly it hangs a lot. after reboot it works fine again.
Tried to cehck the log and I see too many errors on the same pattern.
1914/Td age/Cor/App/Gro/SessionManagement.cpp:330: Session checked out from process (pid=67631, group=/var/www/vhosts/example.com/httpdocs (production))
Node js Error log
Nginx js Error log
1849#0: *327290 upstream timed out (110: Connection timed out) while reading response header from upstream
Any help on this? what is this issue and how to get rid of this?

Node server stop responding to requests after a while

I recently created an e-commerce site using express and the node server worked fine on my local machine. When I uploaded it to my VPS and tried running it using pm2 and with nodemon, the server stopped responding to requests after few minutes, even when the number of requests is low.
Although all the internal functionalities other than request handling were working well. I used a lot of console.log()s in my codes, is this problem due to the excessive use of console.log()?

node server is not working

i am working on angular 6 and node js. While i go to fetch data from database and run node server then at localhost:3000 page doesn't works but when i run ng serve then it works on localhost:4200 but doesn't show data coming from database.
There might be many reasons for that. I can say nothing until I see the code.
But some reasons for that might be 1. 3000 port is not listening to your node it may be busy
2. localhost:3000 spelling should be correct in the browser 3. problem might be in body parser when you use it incorrectly, you will be in trouble.
Hope you will fix it.
Angular is running on 4200 port and node is running on 3000. Both are working on different servers. may be an issue of cross-domain. Implement CORS on Node, as it is receiving requests, this will solve your problem.

Run socket.io chat app in a website that's already running on wampserver

I have recently made this socket.io chat app with the help of online videos. But the problem is I modified the code and now I want to integrate it in a bigger website like a social network.
The problem, apparently, is the code can't find the socket.io.js file even though it is in it. I know you would usually run a server from gitbash, but it is already running one so why run gitbash as well?
The exact error is:
GET http://localhost/socket.io/socket.io.js ERR: NET ABORTED
This is causing all the trouble.
Also, any opinions on doing all of this in php. I can do it in php, it's easy.
You're trying to load the file from
http://localhost/socket.io/socket.io.js
HTTP requests directly to localhost will go to localhost port 80 by default, which you probably don't have a server running on.
Change the source of the js file to the port that your app is running on, should look like this:
http://localhost:3000/socket.io/socket.io.js

Socket.io - invalid HTTP status code on SOME browsers

Just after a few weeks of working fine, our Socket.io started spewing errors on some browsers. I've tried updated to the latest Socket.io version, I've tried our setup on different machines, I've tried all sorts of machines, it seems to work on most browsers with no clear pattern of which work.
These errors appear on a second interval:
OPTIONS https://website.com/socket.io/?EIO=2&transport=polling&t=1409760272713-52&sid=Dkp1cq0lpKV75IO8AdA3 socket.io-1.0.6.js:2
XMLHttpRequest cannot load https://website.com/socket.io/?EIO=2&transport=polling&t=1409760272713-52&sid=Dkp1cq0lpKV75IO8AdA3. Invalid HTTP status code 400
We're behind Amazon's ELB, Socket.io on polling because the ELB router doesn't support WebSockets.
I found the problem that has been causing this, and it's is really unexpected...
This problem comes from using load balanced services like AWS ELB (independent EC2 should be fine though) and Heroku, their infrastructure doesn't support Socket.io features fully. AWS ELB flat out won't support WebSockets, and Heroku's router is trash for Socket.io, even in conjunction with socket.io-redis.
The problem is hidden when you use a single server, but as soon you start clustering, you will get issues. A single Heroku dyno on my application worked fine, and then the problems started appearing in production out of development, when we weren't using more than one server. We tried on ELB with sticky-load balance and even then, we still had the same issues.
When socket.io returns 400 errors, in this case it was saying "This session doesn't exist and you never completed the handshake", because you completed the handshake on a different server in your cluster.
The solution for me was just dedicating an EC2 instance for my web app to handle Socket.io.

Resources