I am having some issues with the MeteorJs app that I am working on. I am working for a client and we are using his dedicated server for our app's deployment. The server has php installed and is already running apache server (a php app is live on server). The server itself is running a version of CentOS.
I bundled my meteor app and uploaded it on server using my cPanel access (it is not root level access). I also created an ssh key and logged into the server using that ssh access.
I used export command to set my MONGO_URL to mongodb://localhost:27017/<db-name> (Version 2.6.3 of MongoDB in installed on server) and PORT to 3000. From here I ran the app using node package "pm2".
Now the issue is that when the app runs it accesses the database for data.
The request is made from client side.
The server receives the request (seen in the live log)
The server fetches data from db and logs it in the terminal.
But then it takes somewhere around 10-15 seconds to send that data back to the client.
There is not extra commands or computation between logging the data fetched from server and returning it to client.
But if I change the mongo URI to my instance of MongoLab, everything works fine and there are no delays. My client prefers that the mongo runs on his dedicated server.
As a programmer I know it would be difficult to answer this question with limited information and no hands-on debugging. But I was hoping someone else experienced this issue and was able to resolve. I just installed mongodb on the server without any further configurations. Is it that I need to install any further packages or do any configurations?
you need to set MONGO_OPLOG_URL to enable oplog tailing feature. when oplog tailing is disabled it takes around 10-15 seconds to send that data to the client.
export MONGO_OPLOG_URL like this.
MONGO_OPLOG_URL=mongodb://localhost/local
Related
I have created an app that connects to a serve on my localhost and sende/receives data.I use mongodb as database and everything works perefectly in the localhost.However I want to server run 7/24 and being connected from all the users.How should I make the server run 7/24 and be reachable from any wifi ?
Not really a "Flutter" question, but anyway, you should explore your options, depending on what you need from a server, check out AWS (Amazon Web Services), Google Cloud Run and such. Also Google owned Firebase - it has nice services with a reasonable free tier.
I also used MongoDB for my backend on a private server, but then switched to Firebase (Firestore in particular) and it works just fine for what I need.
I was using Galaxy to host my meteor app and recently decided to host my app with Amazon Cloudfront serving static webpage (angular client) and connect that to my meteor app running on an EC2 container.
I have the static page working and I have the meteor app on the EC2 container, which points to a remote mongo server, working as well. I am using the meteor-client-bundler package to attempt to connect the client (static cloudfront) to the Meteor server via DDP URL. Here is where I am stuck.
The DDP Url should be my meteor server correct? Hosted at ec2....amazonaws.com)? I feel like it has to be because I have publications and methods on the server I will need to hit constantly. If that is correct, then what if I also want to have two EC2 containers running the same Meteor app? Just like in Galaxy, in case 1 is getting maintenance work done or goes down, I want the backup to take over. How can I set up two different DDP urls?
You should use a custom domain for the server, and use that custom domain in the DDP URL. While using the EC2 address will work, it's better to use a different address, especially if you ever want to move to another provider.
You can use NGINX as a reverse proxy to have 2 or more Meteor apps on the one box. It's not too difficult to set up.
You can also use Meteor up (aka mup) to do multiple deployments to the same box. http://meteor-up.com/ Meteor up will give you a very simple way to deploy, it will even revert to the previous version if something goes wrong automatically. You can even configure it to run letsencrypt to give you https security, and automatically renew the certs.
For anyone who is new to this stuff like I am, I figured out to buy another domain name, use dns (route 53) to a load balancer (elastic beanstalk) which handles multiple ec2s for 1 domain, and then point your ddp from the client to the domain. Boom. Thanks for the help #Mikkel
I am currently looking at possible development models for a device that will be in a clients home. I need the device to run a local copy of Meteor while also being able to get and insert information from a central server in a secure/reactive way.
All sensitive information has not been included in this image
I am required to make a local server as I need to run shell commands on the device. While the device could make HTTP webhook calls, it would be slow due to packet travel time and does not meet requirements.
I know that the local server could connect to the Central Server mongodb which would be ideal, however as this local server is physically located in a clients house, this means that the mongodb password would be exposed (big security problem). Also I would be unable to control what information is sent to the local server. I was unable to find a way to subscribe to an external server, which would be a great solution.
Another way could be that the local server simply use HTTP requests, however another requirement is that Audit requests appear almost as soon as they are issued which is ideal for a reactive mongodb item. A heartbeat wouldn't really fit due to the data/processing overheads and slowness.
The summary the question is: How to make a device to run a local copy of Meteor while also being able to get and insert information from a central server in a secure/reactive way.
Well in the end, I found that you can use cross-server and even CORS connections with https://docs.meteor.com/api/connections.html
So now any aspiring developer can use the DDP framework.
My question, to be more clear, it is to create a server with mongodb on a cloud hosting (for example) and access it through another server.
Example:
I have a mobile app.
I hosted my mongoDB a cloud hosting (ubuntu).
I want to connect my app to the db on the server cloud.
Is it possible? How?
I'm joining this learning and my question was exactly MongoDB to create a server in a way that I could access it remotely.
Out of "localhost"? Different from all the tutorials I've seen.
From what you are describing, I think you want to implement a 2-Tier-Architecture. For practically all use cases, don't do it!
It's definitely possible, yes. You can open up the MongoDB port in your firewall. Let's say your computer has a fixed IP or a fixed name like mymongo.example.com. You can then connect to mongodb://mymongo.example.com:27017 (if you use the default port). But beware:
Security You need to make sure that clients can only perform those operations that you want to allow, e.g. using MongoDB integrated authentication, otherwise some random script kiddie will steal you database, delete it, or fill it with random data. Many servers, even if they don't host a well-known service, get attacked thousands of times per day. Also, you probably want to encrypt the connection so people can't spy on the connection. And to make it all worse, you will have to store the database credentials in your client app, which is practically impossible to do in a truly secure way.
Software architecture There is a ton of arguments against this architecture, but 1) alone should be enough. You never want to couple your client to the database, be it because of data migrations, software updates, security considerations, etc.
3-Tier
So what to do instead? Use a 3-Tier-Architecture: Host a server of some kind on mymongo.example.com that then connects to the database. That server could be implemented in nginx/node.js, iis/asp.net, apache/php, or whatever. It could even be a plain old C application (like many game servers).
The mongodb can still reside on yet a different machine, but when you use a server, the database credentials are only known to the server, not to all the clients.
Yes, it is possible. You would connect to MongoDB using the ip address of your host, or preferably using it's fully qualified hostname rather than "localhost". If you do that, you should secure your MongoDB installation otherwise anyone would be able to connect to your MongoDB instance. At an absolute minimum, enable MongoDB authentication. You should read up on MongoDB Security.
For a mobile application, you would probably have some sort of application server in front of MongoDB, e.g. your mobile application would not be connecting to MongoDB directly. In that case only your application server would be connecting to MongoDB, and you would secure MongoDB accordingly.
I have my server hosted on Heroku. The data source for my app is an external to my app. The following is the way to fetch the data :
Initialize a process that connects to a socket # the external-party server.
Save the data that comes through this socket connection.
Now my question is, Is it possible on Heroku to launch such processes, which needs to run constantly for-ever, listening to a socket on an external server?
A processes in Heroku can only listen to HTTP traffic on port 80. Like andy mentioned, Node.js is your best bet for running a service like this on Heroku.
I think this might be a job for Node.js which you can run on heroku. The logic flow will be to connect to the party server with a node.js app and then when data is received it will trigger a "callback" method. This method can then make a web request back to a Rails server with the data.
For examples of something like this, checkout the pubnub node.js sample app:
https://github.com/pubnub/pubnub-api/tree/master/nodejs
If I understand you correctly you need to launch a background process on heroku that connects to an external server -- this process then saves data from the api locally?
Accessing an external service:
That I'm aware of Heroku does not restrict access to external hosts or ports. Indeed, I have an app that connects to my mongodb database on mongohq.
Long running process: This is certainly possible using the new Celadon Cedar stack. The new cedar stack uses a concept called a Procfile, this enables running any script (e.g. ruby, bash, node.js) as a process.
Saving the data: Heroku has a read-only filesystem (excepting /tmp), so you'll need to save the data coming from the API in a database (or somewhere similar).