Failed to load resource socket.io in nodejitsu? - javascript

I'm trying to deploy a simple chat applicacion in Nodejitsu, and using socket.io.
I use the application localy and it works perfectly but when I deploy to nodejitsu I get the following error in the javascript console:
Failed to load resource
And the chat doesnt work.
I checked to the source code and clicked in the
/socket.io/socket.io.js
and it works perfectly
My package.json is:
{
"name": "Chat_1",
"subdomain": "Chat_1",
"scripts": {
"start": "node main.js"
},
"version": "0.0.0-4",
"engines": {
"node": "0.10.x"
},
"dependencies": {
"socket.io": "*"
}
}
I hope someone could help me, please!

According to the Nodejitsu Handbook "We reroute all traffic to port 80". Double check you're using port 80.
server.listen(80);

Related

Parcel serving on localhost not working : "This site can’t be reached localhost refused to connect."

I am a beginner, i was using parcel and was working great, but suddenly it stopped serving to localhost (http://localhost:1234/) no error with building, localhost shows : "This site can’t be reached, localhost refused to connect".
And also i can serve with "npx serve" no problem.
"#parcel/transformer-sass": "^2.7.0",
"parcel": "^2.7.0",
"sass": "^1.26.10"
I had the same issue, and I believe how I fixed it was by specifying a port in the command.
parcel index.html -p 1234
Also it's a good idea to clear your .parcel-cache every time you restart your server, because sometimes parcel doesn't pick up the changes.
Hope this works for you.

Websocket connection to 'wss://url' failed : [vite] server connnection lost. polling for restart... after deploying the vitejs project in AWS EC2

I have created the vite project it is working perfectly fine in the localhost. But when my project was deployed in AWS EC2 instance, I am getting following error message :
Websocket connection to 'wss://www.domain.com/3000' failed:
[vite] server connnection lost. polling for restart...
pacakge.json :
{
"name": "screen-recording-demo",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"devDependencies": {
"vite": "^2.0.5"
},
"dependencies": {
"firebase": "^8.2.10"
}
}
I have used firebase dependencies in my project in locally everything is working fine. I have checked the vite doumentation, but not getting what needs to be added or I am missing in the production.
based on my experience this a day ago, i need to open the port used
in Nuxt 3 it's 24678, so i must execute these
ufw allow 24678/tcp

Firebase serve error: Port 5000 is not open. Could not start functions emulator

I'm trying to serve firebase functions locally, but when I run firebase serve or firebase emulators:start the error message is: "Port 5000 is not open, could not start functions emulator."
I'm using Windows 10, so I've tried to change the port number, check if the port is blocked by Firewall and I create a new rule in Firewall to ports 5000-5010 but none of this approaches worked for me.
For Mac/Linux, use the Terminal/Shell to find the Process ID (PID), then kill the process.
sudo lsof -i :5000
sudo kill -9 PID
In MacOS Monterey, port 5000 may be claimed by a new "AirPlay Receiver". This can be disabled in Settings -> Sharing:
Screenshot of settings panel for disabling AirPlay Receiver
Disabling the AirPlay Receiver (if you do not need it) frees up port 5000.
Alternatively use a different port, it is a simple solution.
firebase serve -p 5001
For Windows Users:
netstat -ano|findstr "PID :5000"
And then with the Process ID (PID) found at the end of the line.
taskkill /pid FOUNDPID /F
Command taskkill does not work from within terminal of VS Code context. It needs an (elevated) CMD-prompt or equivalent Powershell environment in order to successfully terminate the listening on 127.0.0.1:5000.
The thing here is your port No 5000 is running with some process.
So, first, you need to kill that process.
To find the Process id in ubuntu
sudo lsof -i :5000
Suppose PID you get 14541
To kill the Process
sudo kill -9 14541
Port 5000 and 7000 are taken by airplay on MacOS Monterey.
Switch off Airplay Receiver as suggested here or
update firebase.json with a different port
"emulators": {
"hosting": {
"port": 5004
}
}
lsof -t -i tcp:5000 | xargs kill
A one-line alternative for Mac users that pipes the the process ID directly to kill. h/t #manav
Original question was for Windows, but might be useful for others as question is now ranked highly in search results.
A similiar problem has recently been reported in the official github repo: https://github.com/firebase/firebase-tools/issues/1606.
It is caused by a bug in a dependency (node portfinder), as you can see here. https://github.com/http-party/node-portfinder/pull/86
A quick fix to edit it might be to use the old version of node portfinder (v 1.0.21). Alternatively, you can do it by editing node_modules/firebase-tools/lib/emulator/controller.js and changing yield pf.getPortPromise({ port, stopPort: port }) to yield pf.getPortPromise({ port, stopPort: port + 1 }).
EDIT:
As suggested by Mladen Skrbic, in order to find the firebase-tools folder, you should run npm root -g and find the firebase-tools folder in there.
This should fix the issue!
This worked for me.
Just restart your system.
just run command firebase serve --only functions --host 0.0.0.0
Running this command did the trick for me: firebase emulators:start --only firestore
also close this window:
Try this way:
firebase serve --only functions -p 5002
Instead of latest firebase-functions(which is 3.2.0 currently), forcing it to stay at 3.0.2 solved in my case.
"dependencies": {
"firebase-admin": "^8.2.0",
"firebase-functions": "3.0.2",
...
}
(Also I am using firebase-tools version 7.0.2 atm, didnt check it with latest. If it doesnt work try reverting firebase-tools to 7.0.2)
A quick fix npm i -g firebase-tools#7.8.0
macOS Monterey 12.2 user here. I've simply changed the port to 5005 and it worked like a charm.
{
"hosting": {
"public": "functions/browser",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"function": "ssrapp"
}
]
},
"emulators": {
"hosting": {
"port": "5005"
}
}
}
where is?
node_modules/firebase-tools/lib/emulator/controller.js
I cannot find "firebase-tools" folder in node_modules.
I able to find only firebase-funstions and firebase-admin.
SOLUTION TO: Firebase serve error: Port 5000 is not open. Could not start functions emulator
If you get one of the following error messages when you run Firebase, you can easily resolve the problem by switching to another version of Firebase tools.
Port 5000 is not open, could not start functions emulator.
If you are using version 6 of Firebase Tools, you might switch to latest version (6.12.0), or you might try v7.2.2. To change to Firebase Tools version run to following node package manager command.
npm install -g firebase-tools#6.12.0
If firebase serve --host 127.0.0.1 solves it for you; maybe you haven't set up your hosts file. Linux - Network configuration
I faced the same issue not quite long ago.
I found out I had firebase running on another terminal onmy computer.
So before you try firebase serve, check if it running on another terminal.
I hope it solves your problem just like mine.
first, close all tab restart VS code then just go in firebase.json file then
change ui port number then start again, it will work!
"ui": {
"enabled": true,
"port": "enter any number"
}
As suggested here https://github.com/firebase/firebase-tools/issues/2856#issuecomment-902411134
Upgrading Node.js is working.
I just upgraded Node to 14.17.5. This solves the problem. I just press Ctrl+C to stop all emulators.
close everything, delete your "prefetch" and "%temp%" in "run" option and restart your PC. that worked for me
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"source": "functions"
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"hosting": {
"port": 5005
}
}
}
I'm using macOS Monterey 12.6 ,
I just changed the hosting port to "5005" , and it's working fine to me
For me, it wasn't working when a VPN was on.

Nodemon not reloading page

I am starting studying Node.js, so I am using nodemon to reload my page, but it's not working and already tried all Stack solutions aswell.
Look how simple is my code:
package.json
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.4"
},
"devDependencies": {
"nodemon": "^1.18.3"
}
}
server.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hey');
});
app.listen(3001);
My bash while interacting with res.send() message.
You are using nodemon with the server. It is restarting the server as you make changes to the server.js file. That is, your endpoints are being updated. This will not cause your client to reload. As you are simply navigating to the endpoint that you are creating within the browser, you will not see the changes reflected without refreshing.
That isn't to say that there is no benefit to running nodemon in this way. If you were not doing so you would need to also close the node instance (ctrl-c) and then rerun it every time before refreshing the page. Otherwise, you would still be running the old version of your server and still see the same content served.
Eventually you will consume these endpoints using an http client from your client application, this is generally when you take advantage of a hot reloading environment. There are some options here if you want to make express live-reload before then.

Error after installing Realm: Must first create RPC session with a valid host

I recently installed realm using:
npm i realm -S
react-native link realm
Important edit
This issue only occurs when debugging from device
Everything still works but this time, when I try to enable Debug Js Remotely from the development menu, I get the error Must first create RPC session with a valid host.
Remote debugging used to work and the development server is still running on port 8081 as it used to be.
If there is any code example you want, please let me know. Realm is not invoked until later.
From package.json:
{
"name": "ExampleProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-jest": "^20.0.1",
"babel-preset-react-native": "1.9.1",
"jest": "^20.0.1",
"react": "16.0.0-alpha.6",
"react-native": "^0.44.0",
"react-native-device-detection": "^0.1.3",
"react-native-elements": "^0.11.2",
"react-native-orientation": "git+https://github.com/yamill/react-native-orientation.git",
"react-native-scrollable-tab-view": "^0.6.5",
"react-native-vector-icons": "^4.1.1",
"react-navigation": "^1.0.0-beta.9",
"react-test-renderer": "16.0.0-alpha.6",
"realm": "^1.3.0"
},
"jest": {
"preset": "react-native"
}
}
Error:
Realm's Issue tracker mentioned it once "somewhere" but I couldn't find a fix.
Has anyone seen this message before and can you point me in the right direction to fix this?
There might be a better answer in the future or not at all. So, here's what I found.
I'm not really sure what solves this issue. At least, make sure that realm's port (8082 by default) is reachable on your device by commanding adb forward tcp:8082 tcp:8082 in a terminal.
Furthermore, make sure the device is connected(!) to the same subnet/network to avoid any packet dropping.
Try completely removing the app from the device (reset) in combination with shutting down the packager and re-running react-native run-android / running from xcode.
I don't believe there is a uniform solution yet at the time of writing.
Along with deleting the app from the simulator before re-running, I also erased previously cached contents and settings on the simulator by going to: Device -> Erase All Contents and Settings ... . After this, I restarted the simulator and ran the application and then, the aforementioned error specified by the author, was gone.

Categories

Resources