Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

websocket communication between servers

I read a lot on Stackoverflow, but after a week of thinking and research, I am running stuck...

So I really have to ask :)

Hope I explain the problem correctly, if not, please say!

The problem is simpel. I need 2 servers... Server A - that does nothing more then filling a database every 15 minutes, and server B that does stuff with the data from server A.

Its easy to let server B do a http request for data, but what I really want, is that server B gets a 'socket update' from server A, whenever it has updated the database data.

The problem: is that server B is not always on the same URL.... So the database server cannot simply do a get/post request, cause it will not always know its url.

Thats why I hope, that server B can start a socket.io connection to the database server.. Keeping the line open to server A, so that server A can respond with its new database data, over the already established socket connection....

So basically... Is it possible to have a common socket.io connection between 2 servers.. just like a server between a client does???

Really thanks!!!

UPDATE: To clear it up a bit.

I have a stock database.. It gets all data, every 15 minutes, from a trading API. This server must never stop! It could, but its annoying, cause data will be inconsistent...

I have another script, that is going to be on development all the time.. That does calculations over the data from the database server. So it will have (dev) errors etc once in a while.. This script should not halt the 'database ticker' script... So I want to run them separate from each other. Thats why I need to have 2 servers connecting with each other..

My database is running from a fixed url.. But my development script depends on from where I develop at the moment..

Maybe there is a way better solution for what I'm trying to reach..?

like image 597
DutchKevv Avatar asked Dec 22 '14 15:12

DutchKevv


1 Answers

For server to server communication you can use socket.io dependency on one of them and socket.io-client on the other.

like image 126
zaynetro Avatar answered Nov 15 '22 04:11

zaynetro