Being able to serve my application to a couple of friends over a VPN network.
Configuration 1:
OS:Slackware x64
Node:13.13.0 --- built from source.
Npm: 6.14.4
ng: 9.1.1
ts: 3.8.3. (although the project uses 3.7.5)
Configuration 2:
OS: Win10 64bit
Node:12.16.2 -- next,next,finish.
Npm: 6.14.4 (possibly?)
ng: 9.1.1
ts: 3.8.3. (although the project uses 3.7.5)
Test devices:
Android smartphone (v5 series)
Windows 8.1 x64
Windows 10 x64 All three devices are connected to the same VPN my Configuration 1 and
Configuration 2 are connected to
Iphone on its' own mobile internet connection, connected through VPN to me
Windows 7 machine from another location, also connected only through the VPN
Results with Configuration 2:
when using ng serve --host vpn.address.x.y --port custom --disable-host-check
It works flawlessly for all three devices
Results with Configuration 1:
when using ng serve --host vpn.address.x.y --port custom --disable-host-check
Other than running locally, I can run it successfully from test device 1 (Android smartphone), test device 2 (Win8.1) and test device 4 (Iphone)
but on the Win10 machine, I get a "Loading failed for module with source.... and an error :12:1
On test device 5(Win7) I get the same issue as on Win10
What I already tried:
Building v12.16.2 version on the Configuration 1 (linux)
Just unzipping the node binaries for 12.16.2
Both attempts produced the same result as the current 13.13.0 node I compiled from source, so I hope it's not related to node.
I ALSO tried:
passing --host 0.0.0.0
passing --host my_local_IP
passing --host my_external_IP
passing --port 4200
passing --port 8080
passing --port 49000+ (random numbers, really)
These adjustments changed nothing for either Configuration 1 nor Configuration 2 (on 1, it didn't change for the better, on 2 it didn't change for the worse)
Changing browsers didn't change anything for either configuration either. If it works, it works on all browsers on the target test device. If it doesn't, it doesn't work on any browser on the target test device.
I'm posting this as an angular question since I tested a simple with-slackware-shipped apache webserver on the problematic Win10 machine and that webserver is accessible from that Win10 machine.
(The famous "It works!" message is shown)
UPDATE:
I tested using
ng build
ng build --prod
and then serving the output folder of that command as the directory from which my httpd should serve from.
Results are consistent: If it works otherwise, it works with this as well. If not, then not.
I'm evermore steering away from a possible angular-related connectivity issue to perhaps an issue with windows, perhaps? Only Windows (7 and 10, although not 8.1) failed, while iOS and Android did not?
Any insight or a nudge in any direction will be appreciated. I possibly overlooked something.
Please note, both configurations are on the same laptop machine, so there are no hardware discrepancies, only software.
Related
1. Summarize the problem
I would like for a node/express app.js to listen on a port 3000, on container startup.
I created a CentOS 7 Docker container, installed the software collections (SCL) repo, and then installed node.
I can now enable node with:
scl enable rh-nodejs10 bash, and so I did, and then installed express (globally), and pm2 (globally), and can successfully run a minimal express app listening on port 3000 with commands I run at the command line.
I put scl enable rh-nodejs10 bash in my .bash_profile (of a user I created named: www - because I do not want root running the web server).
In fact, I will be building a rootless container (buildah), next after this, so there will be no 'root' user at all for security concerns.
Now on container startup I want to have the web server start automatically, and be able to get a response from: http://localhost:3000 (hello world).
The problem is that on container startup, node is not enabled for any user until a shell is invoked to enable it.
2. Provide background including what you've already tried
I have searched the web for a solution of using node, express, pm2 in conjunction with CentOS 7 software collections and have found no solution.
Please only reply if you have actually tried the solution your recommend, and have it working, otherwise it most likely will not work.
systemd needs to:
1. enable node
2. run pm2 start app
I tried putting both in a shell, but when you enable node, you are then put in a sub-shell and cannot script any additional commands.
3. show some code
scl enable rh-nodejs10 bash
4. Describe expected and actual results including any error messages
I expect the node/express server to listen on port 3000 on container startup.
I have node running on reboot on RHEL 7 by using scl-utils/scl_source technique found here
$ cat /etc/profile.d/enablenodejs.sh
#!/bin/bash
source scl_source enable rh-nodejs10
I want to start debugging node.js app using Intellij and node.js interpreter running on Docker. While running the app works, when I try to debug I get the error:
Error running 'index.js'
com.github.dockerjava.api.exception.InternalServerErrorException:
{"message":"driver failed programming external connectivity on
endpoint focused_poincare
(a17137973880d1be7c6a74fc142184fdda31e0dec8ebd539b09d9dbe4cf70014):
Error starting userland proxy: Bind for 0.0.0.0:55578 failed: port is
already allocated"}
Remote interpreter was configured acccording to the documentation. I have created a new Node.js Run/Debug configuration and entered the following data:
.
What might be the cause for debugging not working?
I use:
Intellij Idea Ultimate v. 2019.1.4 Preview
Intellij NodeJS plugin v. 191.7479.1, NodeJS remote interpreter plugin v. 191.6014.8 and Docker plugin v. 191.7141.44
Docker Desktop Community v. 2.0.0.3
EDIT: Adressing the comments:
Local debugging works. The file (index.js) that I am trying to run consists only of console.log('Hello world!') so I don't spawn any child processes on my own. My host system has Windows 10 Pro as OS, so for checking the open ports on host system I used netstat -an | find "55578", which returned nothing. Moreover, if I try to run docker manually from the command line, using docker run -it -p 55578:55578 node, everything runs and no error is given.
Also, each time I try remote debugging, the port number given by Intellij in an error message seems to be random high port number. I tried looking for open ports just after getting error message, but never found one that is open with a number reported by Intellij and those indeed appear in the output:
My Run/Debug configuration:
My Docker configuration (I had to check "Expose daemon on tcp://localhost:2375 without TLS" in Docker configuration to make Intellij and Docker play together):
EDIT: When I add --inspect-brk=0.0.0.0:55432 as "Node Parameters" in "Run/Debug Configurations" Intellij windows (per this bug report) the container nad program start, but debugging seems to be no-op (e.g. the program does not stop on breakpoints).
After updating to Intellij v. 2019.2 I was able to get the container debugging to work using the workaround already mentioned in my question.
I have added a parameter --inspect-brk=0.0.0.0:55432 to Node parameters option in Run/Debug configuration (see the picture below) and everything seems to be working, including the breakpoints.
Description
I am on a Mac OS X.
Right now, I have almost 10 Laravel/LAMP projects locally, that I ran using vhost configured with Apache. The awesome part about them is even when I restart my Mac or move between networks, or even close the terminal app/tab of my projects, the Apache is still running, all my local sites will still be accessible.
Goal
Now, I am looking to do the same things with my MEAN apps.
How would one configure something like that ?
Let's say I have 3 MEAN apps.
Example
App1
FE running on port : http://localhost:4201
BE running on port : http://localhost:3001
App2
FE running on port : http://localhost:4202
BE running on port : http://localhost:3002
App3
FE running on port : http://localhost:4203
BE running on port : http://localhost:3003
I'm opening for anything suggestions at this moment.
Can we configure the npm to start in the background ?
BE/API
FE
You can use macOS's launchd to run services in the background. There are a couple good GUI apps that make it easier to create launch services:
LaunchControl ($10)
Lingon ($10) - If you go with Lingon, get Lingon X 5 from the official website instead of Lingon 3 from the Mac App Store; Lingon X 5 is more powerful because it is not limited by Apple's sandboxing.
There's also launched.zerowidth.com, an interactive online tool for creating the .plist files that launchd uses.
launchd.info is also a good resource if you want to set them up manually. Apple's documentation is available too.
If you are having problems with commands not working, I recommend trying these troubleshooting steps:
Convert all your commands to use absolute paths (e.g. npm -> /usr/local/bin/npm). You can find the absolute path of a command by running which with the name of the command (e.g. which npm)
Run your commands from within bash using /bin/bash -c (e.g /bin/bash -c "/usr/local/bin/npm start")
One thing you can do is dockerize your applications.
With docker you can run your applications in a light weight virtual machine known as containers in your computer.
This have some advantages, for example, you can run your app with port 80 inside the virtual machine and expose another port to your machine. You can start or stop the container and so forth.
Go to https://www.docker.com/what-docker for more information.
I'm new to Grails and attempting to implement the Hello World app described at grails.org's Getting Started guide.
I have installed Grails using SDKman on an Ubuntu Server 16.04 VM (VirtualBox, running as a service). My host machine is Windows 10.
I configured two network adapters in VirtualBox: the first a NAT with port forwarding (3022 host -> 22 guest, 8080 host -> 8080 guest), the second a Host-Only adapter.
I can SSH into my VM just fine from my Windows host (using Bash): ssh -p 3022 user#localhost
When I run python3 -m http.server 8080 from that SSH session, it successfully listens on both localhost:8080 and :8080. I can access both URLs from a browser on my host machine.
When I run grails run-app it hangs forever, and none of the above endpoints work from my host.
When I run grails run-app --verbose I see it compile without complaint through "Building 85% > :bootRun". I understand that this is expected behavior, but I never see "Application started" or any similar message. It never starts.
ONE TIME the following command succeeded in building and running the app, creating exactly the result I needed:
grails -Dserver.port=8080 -Dserver.host=0.0.0.0 run-app --verbose --stacktrace
However when I stopped the app and tried again, it failed as before.
I notice that VirtualBox > Settings > Network > Adapter #2 which I had set as "Host-Only Network" has multiple times reset itself to Bridged. I suspect that this reset may have caused my problem. But I don't know how to prevent the reset, or to restore that functionality I so briefly had.
Thanks, anyone who can help!
Resolved! Turns out run-app just takes a LONG time to finish compiling and building, upwards of 10 minutes. So I just needed to wait ~5+ minutes with no visual sign of action before the completion message would show and I could access my site. :)
Using just the default code from react-native init AwesomeProject, when I run the app I get the 'ReferenceError: Can't find variable: __fbBatchedBridge (line 1 in the generated bundle)'.
And, when I 'Reload JS', the app just has the white background rather than any 'hello world' views. I haven't touched any of the code from the init.
Any ideas how to resolve the error?
Screenshot (click to view full size):
Using:
Ubuntu 15.10, 64-bit
Node.js v5.3.0
reactive-native v0.1.7
Nexus 5X, API 6.0.1
I generally see this when the packager hasn't started. Ensure that is running by running react-native start
I had the same issue while using Visual Studio Android Emulator. When the red screen shows up type in the command line
adb shell input keyevent 82
This will trigger the shake event and launch the dev menu
Then hit Dev Settings > Debug server host & port for device and enter <your ip adress>:8081. If for some reason you cannot type in the field you can trigger the text action in the command line by using
adb shell input text <your ip adress>:8081
i solved it using this command
adb reverse tcp:8081 tcp:8081
Thank you rmevans9 and Anonsage for your answers!
I am using HTC One on Ubuntu and there is no menu option, anyway this is the summary of the answers that worked for me:
Create the project
$ react-native init MyProject
$ cd MyProject/
In first console tab run and leave it running as you develop (react-native start alternative):
$ npm start
In second console tab compile and install the project (connect the device to the USB if you want):
$ react-native run-android
Fix ReferenceError: Can't find variable: __fbBatchedBridge:
Find you local ip address by executing ifconfig on Linux/Mac, for example:
inet addr:192.168.0.3
Shake the device to see menu options while app is running (if you don't have "Menu" button)
Go to Dev Settings -> Debug server host & port for device in Debugging section and copy your local ip address with the specific port:
192.168.0.3:8081 (the port can be viewed when running npm start from the first tab)
then go/press Back
Shake the device to see menu options again and press Enable Live Reload (to see changes live when editing)
Shake the device to see menu options again and press Reload JS
This worked for me according to documentation
http://facebook.github.io/react-native/docs/running-on-device-android.html#content
Using adb reverse
Note that this option is available on devices running android 5.0+ (API 21).
Have your device connected via USB with debugging enabled (see paragraph above on how to enable USB debugging on your device).
Run adb reverse tcp:8081 tcp:8081
You can use Reload JS and other development options with no extra configuration
Then Run react-native run-android which will automatically start dev server on 8081 port on your dev machine if not already running.
I encountered this when I had specified different react native versions in my packages.json and my build.gradle file. Making sure they matched, running npm update, and rebuilding from android studio fixed the issue for me.
I had the same problem.
As I followed all the steps mentioned in other answers, I could not resolve the issue.
In my case the firewall was blocking the packets coming from android.
Also If you have submitted your app for the iTunes store, also make sure that your jsCodeLocation is back to the localhost, as shown bellow:
jsCodeLocation = [NSURL URLWithString:#"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
/**
* OPTION 2
* Load from pre-bundled file on disk. The static bundle is automatically
* generated by "Bundle React Native code and images" build step.
*/
//jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];