Expo, java.net.SocketTimeoutException:failed to connect - reactjs

am new to React native Expo I need to add some new modules on my project. "expo": "33.0.0", "react": "16.8.3", whenever I try to run my project am getting Error am not able to run the project. I tried all way to run the project like set REACT_NATIVE_PACKAGER_HOSTNAME='192.168.0.102', firewall off, allowed inbound 19000 port etc. but am getting error.
when I enter expo start -c
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]
Starting Metro Bundler on port 19001.
Your JavaScript transform cache is empty, rebuilding (this may take a minute).
Your native app is running at exp9c305c55e38f4d0e856f59397620314e://192.168.0.101:19000
Logs for your project will appear below. Press Ctrl+C to exit.
then my laptop and mobile is connected with same network and same IP but am getting error and i don't know the port 19000 is different from my wifi
Uncaught Error:java.net.SocketTimeoutException:failed to connect to/192.168.1.20(port 19000)from/192.168.0.102(port 49615) after 10000ms
Please give some solution for it.

It's failing because port 19000 is not open in your firewall. If you use linux OS open this port by running:
sudo ufw allow 19000/tcp

enter image description hereFirst Check are you in tunnel connection?
If you are in tunnel connection then
First : ipconfig
then : set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.103 (IPv4 Address)
then:npm start
It worked for me. Hopefully it will help.

I resolved this by changing the network profile on the connected wifi from private to public.
Expo Error Fix

Related

sudo npm run start Admin permissions error?

I am trying to run react application as sudo on port 443 but it is throwing permissions error as follows. I tried running the react script with root privileges too but get the same error.
Command used is
sudo npm run start
Error
? Admin permissions are required to run a server on a port below 1024. Probably:
/Applications/Google Chrome.app/Contents/Frameworks/Google Chrome Framework.framework/Versions/91.0.4472.114/Helpers/Google Chrome Helper.app/Contents/MacOS/Google Chrome Helper --type=utility --utility-sub-type=network.mojom.NetworkService --field-trial-handle=1718379636,2199499938256335430,15968884667410910440,131072 --enable-features=BlockInsecurePrivateNetworkRequests,CookieSameSiteConsidersRedirectChain,CriticalClientHint,CrossOriginEmbedderPolicyCredentialless,CrossOriginIsolated,CrossOriginOpenerPolicyAccessReporting,CrossOriginOpenerPolicyReporting,DocumentPolicyNegotiation,EnableNewCanvas2DAPI,ExperimentalContentSecurityPolicyFeatures,FeaturePolicyForClientHints,LangClientHintHeader,OriginIsolationHeader,OriginPolicy,SchemefulSameSite,UserAgentClientHint --lang=en-US --service-sandbox-type=network --enable-experimental-web-platform-features --metrics-client-id=22a9279b-1648-45cf-a03c-0ce68df69ad5 --shared-files --seatbelt-client=27 (pid 887)
in /
Would you like to run the app on another port instead? (Y/n)
I checked port 443 and it is available to listen. I also wrote a script to listen on port 443 on localhost and it is able to bind on this port as a sudo user. No luck with the react app though.
I was able to run react app earlier in the same laptop but something changed and I don't know what. The error is anyway about permissions but I ruled out this possibility.
I feel it has something to do with Google Chrome Helper which react-scripts is trying to run without Admin Privilege.
Also, it could be some other package I installed which may have caused the issue.
I am at a loss here and am not sure how to debug it further. Googling the problem didn't help either. Any help to debug or fix the issue is greatly appreciated. Thanks in advance.
Mac OS Big Sur - version 11.4
npm version 7.18.1
I was able to get around this issue, by using this package.json command:
{
"scripts": {
"start-https": "sudo PORT=443 HTTPS=true react-scripts start"
}
}
I met the same issue, and solved by downgrading the node version from 16 to 14, don't know why but works.
The only way I found it to work (especially when you install node and npm using nvm) is to call react-scripts directly:
sudo node ./node_modules/.bin/react-scripts start
This assumes you are in the project / repository directory containing .node_modules. Nevertheless, it is different question whether its correct to npm start with sudo. I was just experimenting to run the dev server on port 80 and it was giving error
Admin permissions are required to run a server on a port below 1024.
And I was unable to fix it with various solutions specified on these links: 1, 2, 3, 4. From these links I mostly tried configuration related solutions as I did not wanted to reinstall node (without nvm).

Node.js application wont start on my public IP

I'm SSHing into a linux shell for a school project. Right now, we're trying to set up a react app for a web frontend. We were able to run the app on localhost easily enough, and all of the functionality seems to be good, but I can't figure out how to get this hosted on the public IP of the computer. We've been using yarn to do all of this, though i've tried other things, so here's some cli output.
path/to/thing# yarn start
yarn run v1.22.5
$ react-scripts start
Attempting to bind to HOST environment variable: public.facing.ip.address //This is a website name
If this was unintentional, check that you haven't mistakenly set it in your shell.
Learn more here: //There was a link here but SO formatting wouln't let me keep it.
Could not find an open port at public.facing.ip.address.
Network error message: listen EADDRNOTAVAIL: address not available public.facing.ip.address //numeric
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
root#computer:path/to/thing#
When I run hostname -I, public.facing.ip.address does not appear at all. So that seems like the obvious issue. The catch here is that we are also running jenkins on a separate port of public.facing.ip.address from this same computer. That was much easier to set up, it just came as something I could start as a service using 'systemctl start jenkins' and up it went onto the public facing IP. I set all that up and I can access it just fine, etc. The best I can do with this is modify the HOST variable either in the terminal or the .env file, then yarn starts a development server on localhost (which I can't access since I'm on a different network SSHing into this computer)
How do I make yarn host our webapp on the public facing IP?
open your router page, there should be dmz host option somewhere, point it to your local ip address
My networking inexperience was the culprit. Instead of using HOST=path.to.public.ip, the solution was to use HOST=0.0.0.0.

How to see console.logs of a running nodeJs application on ubuntu 18 EC2 instance?

I am new to the node world. I created a node js rest API. When I run npm start in my local machine or in the terminal for the first time, I can see console.log() in my terminal. Now, I am running the same application on an AWS Ec2 instance with Ubuntu as os. I run npm start and serve my app on port 80. I do this via ssh and after running my server I close the ssh connection. But when I reconnect via ssh, I want to see those console.log() messages in my terminal for some purpose.
I completely understand that logging messages in the terminal is not a good idea and there can be so many alternatives. Just want to know how to access the same terminal window/result as we see when I start my application.
if you are using pm2, you can try "pm2 logs"
So Nodemon won't work well in a production server or in any instance where you need to have the app going by itself.
Nodemon is a dev tool to enable you to restart your server during development. In a "real" vps you need to place the process in the background or it will be automatically killed when the connection times out.
Check out this YT series for a correct deploy architecture in an NGINX server with the use of pm2 and NGINX on a Red Hat server, I've personally used it more than once:
https://www.youtube.com/playlist?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

React Native 0.60 connection to development server

(I'm almost a newbie in React Native development) today I have started a new project in React Native 0.60 (react-native init MyApp).
After that I typed : react-native run-android to check if everything worked.
After the bundle process is finished
I can finally get my welcome screen in my connected devices
But, if I try to reload the app from my devices I get this error:
How could I address this error ?
EDIT: Thank you for your answers, anyway, I have tried all solutions you suggest but I still get the same problem. I also noticed that when i run react-native run-android Metro Bundler (open in a new cli window) seems to start but it suddenly disappear. I think the problem could be with the message 'Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0'
react-native run-android not working in new react-native version
0.60
now you can use
react-native start
OR
npm start
both command is work
Please use the following two commands and then can start the react native again.
- adb reverse tcp:8081 tcp:8081
- killall node
Then you can run the following the command.
react-native start
Now you can run your application again.
Have a good day.
You need to connect your phone to the server, follow the below steps:
[For detailed help follow this https://facebook.github.io/react-native/docs/running-on-device]
1. Open the developer menu on phone.
2. Open 'Debug server host & port for device'.
3. Type in your machine's IP address and the port of the local dev server (eg. 10.0.1.1:8081). If you have connected over wifi then this will be your computers ip address. (If you are running in your computer I think instead of ip address it would be 'localhost:8081')
4. Go back to the Dev menu and select reload.
Hope it would help.
You need to run adb reverse in the Android Studio terminal so your device can connect to the server. Open Android Studio and click on the terminal button at the bottom. In the terminal, and with your device connected to your computer, enter the command adb devices. This will list the name of the connected Android device. Copy that name. Then enter this command adb -s <device name> reverse tcp:8081 tcp:8081. When you run that command replace <device name> with the name of your device you copied from the other command.
Here is a link to an explanation in the React Native documentation

Docker and Chromium net::ERR_NETWORK_CHANGED

I have an AngularJS application that does an ajax call but it results in a chromium error:
net::ERR_NETWORK_CHANGED
I tried to disable any adapters that I don't need. I have multiple ones and multiple dockers containers running.
I disabled ipv6 on each adapter. I don't use any proxy and use default Chromium browser without any addon nor browser profile.
Disabled Wifi interface, only using ethernet.
Any idea how to fix this?
I was constantly getting ERR_NETWORK_CHANGED.
This is what finally worked for my current browsers:
Chromium, Opera and FlashPeak Slimjet.
sudo service docker stop
The following actions did not solve my issue:
Checked modem, router, and cables to isolate the issue.
Disabled IPv6 from my wired Network
Commands:
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
After I stopped Docker, I am not getting any more console errors.
I hope this can help someone saving hours of annoying troubleshooting.
Ron.
sudo service docker stop
But this is not a solution because I need docker in my daily work.
So I found out that docker networks cause this problem
docker network prune helped me
Or try to delete one by one except of none, bridge, host
Based on the original answers, I want to go into more detail what fixed it in my case.
Stopping the docker service sudo service docker stop in my case fixed the issue.
The underlying issue one of my docker-compose setups having restart=always.
Unfortunatly I had a bug causing a container to terminate and restart. This restart caused the network change.
It is determinable by running docker ps and noticing the container restarted.
I fixed the problem and ran docker-compose down for my docker compose setup. Both actions would fix it independently.
Furthermore a Bugreport for chromium exists regarding this issue, but it has the state wontfix.

Resources