We are using Openfire (Jabber) to enable chat and presence capabilities to our MMORPG. In our server architecture clients only open a single connection with the game server, and upon login, the game server creates a new connection to Jabber for this new client.
The problem is, we don't want to open a new connection to Jabber for every client that logs in, we like it better if our game server acted as a connection manager and talked to the Jabber server through a single connection, yet being able to manage hundreds of thousands of 'logical' clients.
Is this possible?
Any links or info on this matter would be very much appreciated. Thanks.
Why not have a local Jabber server separate from your game server, but on the same network and let it handle all the messy details?
If you have a massive game, you will most likely also need massive network.
There is already a connection manager for Openfire, open-sourced (though it does need an external library as well that is not OSS). It connects to the clients and from there talks to the main server as a jabber component. It sounds like you want to be able to do a similar thing with your own system.
Related
I'm trying to create a desktop app with RMI (Java) for school. It's a simple chat app and I found plenty of examples about creating a chat app with RMI.
The "problem" is that I have to make this app fault tollerant, so my professor asked me to create also a peer-to-peer connection between clients if the server doesn't work.
So I have to create two types of connections: client/server and peer-to-peer.
I have two questions:
1) Which is the best way to save the data in the local client side in order to access them if the server doesn't work?
2)Can I create peer-to-peer connection with sockets or there is another way on doing this?
Thank you very much.
1.You should detect a remote exception error or server is when unreacehable using
try {
}
catch(RemoteException ex){
//do some peer - to -peer look up here or other way
}
in your client code which tries to connect to server and when accessing a STUB on RMI. Second , you need a central server location that Peer-TO-Peer data exchange is possible.AT least when every peers comes in to connecting to the central server(RMI server) or want to chat additionally it needs to record some information about him self in some other shared data repository.This not the best answer but ,just an ice breaker.
2.Sockets and Yes sockets are pretty enough for peer-to-peer connection!!
I would like to connect to an REST Web Service through a VPN. Is there a way in Java to establish an pptp, l2tp ipsec connection to the VPN gateway an tunnel the HTTP request, without using the Operation System functions? This is important because I will connected to several rest services from a servlet. This Services could be behind different VPNs and I do not want to connect the network of the server with this VPNs.
Do anyone know about an API for that?
If you want to connect to a server behind a private VPN, from the outside, nothing you can do on you app can/will allow you to do connect. Unless you launch a VPN client and programmatically connect your network, to that VPN server, your java app will just sit there waiting for a socket on http connect.
Your question is technically incorrect (not from the SO point of view).
Look for a VPN client library that will pop up a dialog and take username/pwd.
A VPN has the purpose of connecting networks. If you want to reach another system via a VPN you will have to establish a network connection.
a Java API for all of this protocols will be (nearly) impossible, since VPN is handled by OS drivers and not on the application level (where java has its place) in most cases.
If you don't want to have your physical server being connected with those VPNs, you could perhaps set up a virtual system with virtualbox or vmware (or others) which handles all those connections and use it as a proxy. But this is no java issue than.
Here is a simple Java API that allows you to use Nord. I've made several bash scripts that also allow me to start, end and cycle NordIKE-VPN sessions. I have not used this yet, but I am intending on repurposing it for use with Android.
https://github.com/yaniferhaoui/NordVPN-Public-Java-API
I'm trying to make like a skype-instant messager, my idea for it is to have
one server which handles multiple connections for the clients. What I now have is a friend list etc, but now I want to create Threads both for server and client to handle a conversation. The problem is that I need multiple connections between a server and one client for every conversation(I think). but i dont think it's possible. Does someone have another way for doing this or maybe a way to make multiple connections between the server and a client?
Thanks for helping me out
PS: English is not my main language so please excuse me for my grammar.
I think the best is that you always make one tcp connection from each client to the server, that way if your client is behind a firewall or router the connection can be established anyway.
Then you need to define a protocol with control messages, like "create new conversation with ...". And the server can generate a guid for each new conversation, then client can receive and send messages togheter with the conversation id always through one connection.
Update:
To answer the original question: yes, you can make multiple connections between client and server. Each connection should be opened from the client to the server port, once established, each one will have a different port. You can make a thread to deal with each connection or have on thread dealing with all connection using non-blocking calls.
I am developing an application which runs on a desktop or laptop having wifi. In my application I want to connect my desktop and multiple android device through wifi, and I need to transfer data between them.
How can I do this? Is there an API for wifi in Java SE? How can I connect to different devices through wifi?
You don't have to bother how the network connection is established in the operating system. Open a connection and that's it.
First off, you're confusing the network stack or what I originally learn as the 7 layer OSI model. The wifi connection is down in layer one and typically when you're writing software you don't go anywhere near this layer.
Software usually connects at levels 5 and above. The java.io package provides the classes needed to do this, leaving you to decide whether to work with a direct socket connection or use on of the protocols in the higher levels such as http.
My advice would be to use http as your protocol with Tomcat or similar as your server, putting the logic you need in servlets or JSPs as appropriate. Sending http requests from Andriod is explained here.
I have to design a client/server system emulated on a website running Ruby on Rails that should work like this:
a page is requested by a web browser and once it's opened the server can push messages to it
I know this is not possible "naturally" but I was thinking of a sort of "java applet" that is running on that page, listening on a port for messages to be sent by the hosting server. This should be done opening a sort of a socket that listens on some port where the server can connect to send its messages.
Can this be done? Do I have to develop a java server thread or can I simply address the client applet via it's ip address and port and use any web service connection from the server?
thanks,
Luca
Comet is definately what you want. Depending on your needs, you can host your own comet server, or use a SaaS solution, such as WebSync On-Demand (disclaimer: I work there). Using the SaaS stuff, you get server-push capabilities without having to actually run your own comet server.
The easiest way to do that is to use Javascript to emulate the push mechanism. Polling in regular intervals using AJAX is sufficient in most cases. Have also a look at Comet.
An alternative to using a java applet may be to use a combination of javascript and an approach known as Comet. In a nutshell, Comet is a way to enable server push over HTTP. I'm not really a ruby on rails guy, but a quick google search for ruby on rails and comet nets a fair amount of useful information.
have you looked at juggernaut
If you want go the applet route, you need to make the connection from applet to the same server where the web page is served. The applet can't listen. Once the TCP connection is established, it's a 2-way channel, you can pull or push as long as your protocol allows it. This is how it's done with most Applet-based chat clients.
More and more people are simply using long polling in Javascript. It's pretty involved to get a reliable long polling system running, I would suggest you to use a framework. For example,
http://cometdproject.dojotoolkit.org/