MongoDB react app working locally not in heroku - reactjs

I am trying to deploy a react site with Heroku everything is working except the data from my MongoDB Atlas is not sending to Heroku. The app is working as it should locally, I have tried everything I have seen on the help section and I am not sure what to do next.
This is where I connect the MongoURI to the heroku app
This is where the cluster is shown it is connected in Heroku tails

Frequently you cannot connect to your cluster from a non-whitelisted IP i.e. your Heroku's server IP. To test this - if you have a test env or the project doesn't have any data in it yet, you can open up your cluster to the world, check that the data is being pulled and then enable white-listing and add your server's IP. For maximum security you don'y want to open up your cluster to all connections, instead just add you IP.
Refer to the screen attached. In Atlas panel, go to your cluster, Network Access and click ADD IP ADDRESS. This might look a bit different for you if there are no address there yet - then follow the config wizard.

Related

live ip not directing to the react-app index page on lightsail server

I created react-app on amazon light-sail server, and it shows running in the terminal. but when I hit the live IP, it takes me to the by default web page that was there. How to map the live IP with the react-app homepage. Also plz know that it was created in a new folder and then used create-react-app command no previous apps were removed. Its node server where it is installed. Thanks
Its resolved. Actually, the port was not allowed, so once i allowed the port then it started working. Go to Networking and in ipv4 networking add the rule to allow the port.

What is the equivalent of a hosts file mapping for AppEngine?

Our AppEngine app is connecting to a remote service which requires a VPN and also required me to add entries to the hosts file on my local machine in order to connect to their endpoints.
e.g.
10.200.30.150 foo.bar.com
This is working fine when running the app locally, but I can't figure out how to set this up on Google Cloud to work once deployed.
I can't use the IP addresses directly because it errors that the IP is not on the cert's list.
How do I map the host names to the IPs in Google Cloud so that AppEngine can use them?
From the error mentioned in the comment I suspect connecting directly through the IP fails because the certificate doesn't recognize the IP to DNS mapping as valid and therefore the secure connection setup breaks. Based on the requirements of connecting to the API by VPN and tweaking the hosts mapping there are few things you may try.
The simplest approach that may work would be using a Google Compute Engine VM instance, since there you would able to manipulate the etc/hosts file and replicate the local machine setup. This VM could be used either as the main app service or as a proxy from App Engine to the 3rd party API endpoint. To go that route I would suggest taking a look at these two posts which explain how to change the etc/hosts file on GCE (Changing the file once wouldn't work as the VM periodically overrides it, see the posts for cronjob like workaround).
Separately, as your app runs in App Engine flexible environment there is the chance to provide a docker container with the app packaged. It may be possible to set the workaround above in the docker file and have it working in App Engine too.

How to host grafana on azure cloud?

i have followed the https://grafana.com/docs/project/building_from_source/ and set up grafana in my local physical machine. Now am running it using yarn start and also starting grafana-server and it is working perfectly fine. Now i want to move it to Azure.
I am completely new to hosting procedures hence i would need some step by step instruction to host the created grafana over there in Azure
There is no managed service for graphana, you need to install it on a VM using an existing image or manually, you can find the image from the market place
here is a more detailed step, and it helps me out
https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-monitor/platform/grafana-plugin.md
Using the IP address of your server, open the Login page at HTTP://:3000 or the :3000 in your browser. While 3000 is the default port, note you might have selected a different port during setup. You should see a login page for the Grafana server you built.

Debugging GAE microservices locally but without using localhost

I would like to debug my Google App Engine (GAE) app locally but without using localhost. Since my application is made up of microservices, the urls in a production environment would be along the lines of:
https://my-service.myapp.appspot.com/
But code in one service can call another service and that means that the urls are hardcoded. I could of course use a mechanism in code to determine whether the app is running locally or on GAE and use urls that are different although I don't see how a local url would handle the since the only way to run an app locally is to use localhost. Hence:
http://localhost:8080/some-service
Notice that "some-service" maps to a servlet, whereas "my-service" is a name assigned to a service when the app is uploaded. These are really two different things.
The only possible solution I was able to find was to use a reverse proxy which would map one url to a different one. Still, it isn't clear whether the GAE development SDK even supports this.
Personally I chose to detect the local development vs GAE environment and build my inter-services URLs accordingly. I feel it was a well-worthy effort, I've been (re)using it a lot. No reverse proxy or any other additional ops necessary, it just works.
Granted, I'm using Python, so I'm not 100% sure a complete similar Java solution exists. But maybe it can point you in the right direction.
To build the per-service URLs I used modules.get_hostname() (the implementation is presented in Resolve Discovery path on App Engine Module). I believe the Java equivalent would be getInstanceHostname() from com.google.appengine.api.modules.
This method, when executed on the local server, automatically provides the particular port the server listens to for each service.
BTW, all my services for an app are executed by a single development server process, which listens on multiple ports (this is, I guess, how it can provide the modules.get_hostname() info). See Running multiple services using dev_appserver.py on different ports. This is part I'm unsure about: if/how the java local dev server can simultaneously run multiple services. Apparently this used to be supported some time ago (when services were still called modules):
Serving multiple GAE modules from one development server?
GAE modules on development server
This can be accomplished with the following steps:
Create an entry in the hosts file
Run the App Engine Dev server from a Terminal using certain options
Use IntelliJ with Remote debugging to attach the App Engine Dev server.
To edit the hosts file on a Mac, edit the file /etc/hosts and supply the domain that corresponds to your service:. Example:
127.0.0.1 my-service.myapp.com
After you save this, you need to restart your computer for the changes to take place.
Run the App Engine Dev server manually:
dev_appserver.sh --address=0.0.0.0 --jvm_flag=-Xdebug
--jvm_flag=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
[path_to_exploded_war_directory]
In IntelliJ, create a debug configuration. Use the Remote template to create this configuration. Set the host to the url you set in the hosts file and set the port to 8000.
You can set a breakpoint and run the app in IntelliJ. IntelliJ will attach to the running instance of App Engine Dev server.
Because you are using a port during debugging and no port is actually used when the app is uploaded to the GAE during production, you need to add code that identifies when the app is running locally and when it's running on GAE. This can be done as follows:
private String mServiceUrl = "my-service.my-app.appspot.com";
...
if (SystemProperty.environment.value() != SystemProperty.Environment.Value.Production) {
mServiceUrl += ":8000";
}
See https://cloud.google.com/appengine/docs/standard/java/tools/using-local-server
An improved solution is to avoid including the port altogether and not having to use code to determine whether your app is running locally or on the production server. One way to do this is to use Charles (an application for monitoring and interacting with requests) and use a feature called Remote Mapping which lets you map one url to another. When enabled, you could map something like:
https://my-service.my-app.appspot.com/
to
https://localhost:8080
You would then enable the option to include the original host, so that this gets delivered to the local dev server. As far as your code is concerned it only sees:
https://my-service.my-app.appspot.com/
although the ip address will be 127.0.0.1:8080 when remote mapping is enabled. To use https on local host however does require that you enable ssl certificates for Charles.
For a complete overview on how to setup and debug microservices for a GAE Java app in IntelliJ, see:
https://github.com/JohannBlake/gae-microservices

How to connect heroku app with openshift app database

I am having app on Heroku and of course on Openshift
Now, I would like to use a common database for them. So, how should I connect Heroku app with the Open Shift app database??
OpenShift blocks all incoming ports EXCEPT 80, 443, and 22.
Like the answer above you will either need to set up a SSH tunnel with port forwarding between your two server (which seems VERY fragile to me)
OR
You can set up a web service on your openshift server to handle all the DB requests. This is what happens when you use something like mongolabs or fusiotables with heroku. The difference here is that you would need to write your own web service to expose the database.
You can use port forwarding for this kind of work,Try these article http://bitsofinfo.wordpress.com/2012/06/05/how-to-access-your-openshift-mongodb-database-remotely-on-os-x/ or,
Otherwise you can use a piece of software which runs on your openshift server,which remotely execute your commands on database.For that try Google and note that The ports 0 to 18000 are blocked to incoming traffic.

Resources