4

My project architecture is somewhat like this :

I have an Mobile Application, which i use to upload a form and a photo. This application is connected to a server( Server B ). Using this server, i upload photo to s3 and save form data into database.

There is another server( Server A ), which i use to get data from database and view that data on client-side.

Now the problem is - i want to make this process real-time. I tried to use socket.io but that didn't work. I can send data using socket.io to the all client's but how to know that when data is changed in db ?

Is i am doing something architecturally wrong ? Anybody has any idea how to solve this kind of problem ?

Note : I am using different servers because these two are different applications. If one server goes down then it doesn't has any impact on other process.

gauravmehla
  • 686
  • 6
  • 21
  • Please take a look at the below link [enter link description here](http://stackoverflow.com/questions/9691316/how-to-listen-for-changes-to-a-mongodb-collection) – Akshay Mehta Feb 13 '17 at 10:10
  • actually what is happening , i am storing data from one server and fetching from another.. so i can watch for output in first server which i dont want. i want that when server B stores data , somehow server B knows that this data changed and then it will update the view on client side @AkshayMehta – gauravmehla Feb 13 '17 at 10:45
  • You need to have a process (usually called a worker) which is polling for changes in the DB (or add some kind of trigger to the db when data is changed). When a change happens the worker can communicate either with your web server via IPC (interprocess communication, can be anything, http, websocket, message sub system) then from there you can decide to push that on through via web sockets – Callum Linington Feb 13 '17 at 12:16

0 Answers0