I have a chat application in java using nio it's working fine now. I want to split my chatserver into 2 with the same portno.
Simply :
I want to Split single my server into two or three. When client
logins, it first connect to the first server.
When the first server have 10 clients then 11 th client must
connected to the Second server. and same mechanism for third
server.
These three server must have same port no.
These server must have an internal communication. If client 1 is
logged into the server 1 . Any details got in server 1 should be
known by Server 2 and Server 3.
A client in server 1 must have to communicate with clients which
are in server 2 and server 3.
How can I make these possible is there any example related to this. I googled it but couldn't find any appropriate solutions.
please guide me to resolve these.
Thank you very much.
You can use load balancer which redirects request as per server instance health, you can expose server health parameter by no. of connections that server have. for inter server communication i recommend to use apache activemq and shared database is also good idea
Related
I have 3 computers, on the same local network. Computer #1 is a TCP server and computers #2 and #3 are TCP Clients.
When the server starts I am trying to find the IP Addresses of all available clients automatically, so I don't need to enter the IP addresses manually.
I have limited networking experience, can someone please list the ways to do the above?
There are at least 2 ways:
Send a UDP Broadcast message to every computer on the network from server and clients will reply back their IP. This seems not ideal.
Somehow (not sure how) the server set's up a hostname, e.g. "http://localhost//myapp" and clients check every few seconds if the hostname is up and then connect to server. This seems to be implemented in Java RMI.
I am trying to archive my goal using the Java API if possible and avoid writing much code.
I am busy with a project where I'm creating a basic client/server chat application which allows a user to create a server on their local network on a port of their choice and then have multiple clients connect to that server by specifying the IP and port number of the server(So far so good).
I would like to how I can have clients see all the possible servers they can connect to on their local network when there are multiple servers running on their local network over different ports and then allowing them to connect to one. I am using basic Java socket programming for this project.
You could have
use a UDP based protocol where each server publishes it's IP:port every second.
you could have a service where each server registers. You could chat with that to get the list of all services.
The nice approach of the later option is you can use one of your chat services for server discovery. When you want to get the list, you send a message to a channel on that server which all the servers are listening to and they respond with a chat message.
I've got a project to work on and I need to build some client - server applications where I can send messages and whatever, in Java. One goal of the project is to deal with failover. When a client is connect to a server and the server dies, it automatically connects to the backup server. What I want to do is not required but I want to implement a load balancer so multiple clients get connected to the prefered server.
The connection between a client and the server must be with TCP sockets.
This is a schematic of the network architecture:
client connects to the load balancer (udp or tcp, I don't know the
best one for this situation).
load balancer decides the which server should that client connect (the most empty one)
the client creates a TCP connection with the specified server
My question is:
How should the load balancer work to get a client to connect to specific server? Send information of the server (ip, port) to the client and the clients creates another socket with the new ip? (blue line).
Or is there a way for the load balancer to connect those two end points (server #1 <-> client #1), without having to send information to the client?
PS: I'm asking you because it seems unnecessary for each client to have to create 2 sockets to get connect to the server (first socket black line, second socket blue line)
i think after the client sends information to the load balancer,its best if the load balancer sends that information to the server which it decides instead of sending something back to client and client connecting again to server
I have a java requirment contains both client and server side program.
Server side
Server program frequently check the data base and checks if a new order came, if order came it check the order and send it to the corresponding client machine using IP address and port.The client machines are out side the LAV and has static IP address.
Client side
Client program listen a its on port , when an order came, read it and process.
For implementing these app, which java package is best,java socket communication or any other.Anybody know please suggest one.
Help is highly appreciated,
Thanks,
vks.
Don't go for low level programming like Sockets etc. Use RMI. Your program will have following two entities
Server side :
An RMI Client for calling client machine to send update after checking the database
Client side :
An RMI server application listening for Server update requests and do processing.
If you are new to RMI check out this tutorial . You can search for better tutorials if don't find these good enough :).
I remember I had to do something similar in the university and I used JMS (Java Messaging Service), documented here:
http://www.oracle.com/technetwork/java/jms/index.html
The Server will create the messages from the DB by checking it periodically and will send messages to the clients which will process the info.
I am new to java.I need to develop a proxy server for IBC 2011 conference.I have some Questions regrading the Proxy server.
1.I am going to develop the proxy server using java.
Suppose A(sending the information) to B(receive the message) through the proxy server.
Here A is sending the information through HTTP serves(application running in A is a wed application) how can i receive the information send by A in proxy server and how can I forward it to the B which is also a HTTP serves.
2.What r the Things I have to now before I start developing the proxy server.
3.How can i get the information from the HTTP protocol.
4.How can i check frequently for the any message is there in line to forward to B from A or B to A.
Can any one helpme.Thanks in advance.
Use one of these instead http://proxies.xhaus.com/java/. Rolling your own proxy implementation will be much harder than you think once you've taken all the intricacies of HTTP into account.
there are many libraries which can you use.
for the A and B they can running hessian server(for listening) + client(for sending)
and for the proxy server you can use JMS + hessian server + client same as for A and B.
In this way you can send java objects.
But hessian is only on suggestion you can use RMI or spring remoting or maybe web services.
By far which a have working hessian is the fastest and very easy to develop.
from 1 to 4 you ask how to design a application which is out of the scope and you need to do it by you self :).
I did something similar in my course project.
As far as i am concerned, the core knowledge u need to learn about java for this a proxy server is socket programming.
you can setup two sockets: one communicates between your proxy server and the web browser, the other communicates between your proxy server and the target server.
Also, you will need some knowledge about thread in Java, open one thread for each connection will be a efficient way.
And I assume that you already have the knowledge about those computer networking stuffs like http, tcp.etc.