Xmpp Vs Websocket [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm about to develop a website that has near real time chat. I know that it can be implemented using xmpp or websocket protocols. I know also that the xmpp protocol has been developed in 1999 , and I guess it should be mature nowadays .On the other hand , the websocket protocol has been developed in 2011.
What was the need for websocket if xmpp was good in handling real time conversations?
What are the major differences between the 2 protocols?
And when should I choose one of them over the other?

The short answer is 'both'.
XMPP is a set of application protocol for doing real-time chat (and many other things, for that matter) - it then has to be transported across the network somehow, so you need a transport binding. There are three main transport bindings for XMPP -
TCP/IP, which is what one usually uses on the Internet with native clients on devices
HTTP (called BOSH), which is what one has traditionally used when using XMPP in the browser (as TCP-IP isn't available to Javascript apps in the browser)
Websockets, which is one one uses when doing XMPP in a modern browser.
So if you're developing a chat application in a browser, you'd choose XMPP as the application protocol and you'd use websockets (in a modern browser) or BOSH (in an older browser) as the network transport. If you use an XMPP library for Javascript like Stanza.io (https://github.com/otalk/stanza.io), it'll support both and you'll just be thinking about 'XMPP' rather than the transport layer, other than at setup when you have to tell it what endpoint to connect to.
(You can't use 'just websockets' for chat - you can use websockets without XMPP, but what this really means is that you're inventing your own application-layer protocol for chat, and the odds are you're going to save a lot of time and headaches by taking advantage of the work that's already gone into writing one with useful properties (security, identity, extensibility etc.) and for which there are existing libraries and servers by going XMPP instead.)

Related

How to make proper server connection without storing client URLs on the server [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I am implementing a rather simple communicator - one broadcast chat and multiple others for private messaging between users/clients. The purpose of this app is educational and I want to use solutions that are (preferably:)) simple yet modern, flexible, and used in real life, I started implementation using RestController and I stored clients' URLs in the database but I quickly understood that this is not good practice. I want to ask about links and resources that may address the following questions:
How to make a flexible and secure connection between server and client without storing the latter URL?
What is the correct protocol for information exchange in this kind of application
One way to make a flexible and secure connection between a server and its clients without storing their URLs is to use WebSockets. WebSockets is a protocol that allows for full-duplex communication between a server and its clients. This means that the server and the clients can both send and receive messages at the same time, and the connection remains open until it is closed by one of the parties.
Using WebSockets, the server can send messages to specific clients or broadcast messages to all connected clients. This allows for both private messaging and broadcast chat functionality in your application.
You can use a WebSockets library such as Socket.io for Java (https://github.com/socketio/socket.io-client-java). This library makes it easy to set up WebSockets on the server and handle incoming and outgoing messages from clients.
Some resources that may be helpful for learning more about WebSockets and implementing:
The WebSockets API: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
Socket.io: https://socket.io/
A tutorial on using Socket.io for real-time communication: https://socket.io/get-started/chat/

Creation of a client-server desktop application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I've in the past created client-server web applications using Javascript, AJAX, Node, Express and MongoDB, but now I'm required to creare a client-server desktop application. It will therefore basically consists of a desktop program which will connect to a server program by doing requests. The server program will respond to the client program with the requested data which it can fetch from the database.
Since I'm really new to these kind of applications in Java, I have no idea how to create such an application in Java. Since the project will be large, we cannot hard-code all the server. We need probably a framework on the server side that listens for requests, but I've not found any for now. For example, Play Framework seems only to work for web applications. Which frameworks are useful for these purpose? Is this the right approach for this kind of applications? How would I connect client and server applications?
Please, do not suggest "use sockets". This will be quite a big "serious" project, and we need high level tools. We don't know how usually these kind of projects are created. Please, explain a little bit which patterns are usually used. Examples of concrete programs, maybe with open source code will be useful for us to understand. Also a list of the requirements that we need for these project would be very useful.
Note: I'm not asking for a exhaustive list of frameworks that we can use. I rather asking which kind of tools (with concrete examples) should we use and how to combine them. How to structure such a project.
You could write the server side application in Node JS or whatever other server side language you prefer - and implement that using REST services. Then in your Java desktop application, it would just communicate with the server using HTTP REST / SOAP etc.
That way if you were to then want to swap to use something like .NET to make your desktop application you would be free to do so without it changing anything on the server side. Also you would be able to implement a mobile application / tablet app / other web application and reuse all of the server side implementation easily without changing anything server side.
Another option is to use ServerSocket for the Java server side, and then connect to that from the client but you seem to know and dislike that option.
Another option to connect each side of the application would be to use some kind of pub / sub middleware messaging service - check out JMS as a framework - you will need some kind of implementation of JMS such as Active MQ, Websphere MQ or one of the many other free implementations. Check out : http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html
Difficult question to answer, but those are 3 high level options.
Use web technologies to connect client to server HTTP REST, or SOAP
Use ServerSockets and Socket connections and do everything manually
Use a messaging framework such as JMS

In building chat application, is Web Service better to use than JMS, RMI, or Socket programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
In building java chat application, is Web Service better to use than JMS, RMI, or Socket programming?
My VPS has the ff: 512MB Memory, 1 Core Processor, 20GB SSD Disk and 1TB Transfer.
My target number of users in the same time is, 5-30.
I think the way to handle the changes in chatbox is using Polling.
Is my VPS can handle that load if I am using web service?
If I am going to use other technologies like RMI or JMS?
Is my VPS can handle it?
If you have a web frontend for your chat, using websockets (if you want to use java on the backend, it's supported by jetty but also by other http servers) instead of polling is a more common approach.
Definitely no JMS,RMI or sockets, if the client is a browser, if it's a desktop client using something based on sockets and a custom protocol could be the easiest way to go.
The number of connections your VPS will handle is dependant on many factors, included how performant your application will be.
You should give node.js a try. Search for "node.js chat apps".
Node.js chat server app is going to have very little memory footprint giving you more memory for the server at runtime.

How to use the VPN API on Android? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I'm exploring VPN Connectivity in Android.
I want to know how to setup a VPN connection in Android using an application.
I came across some sample code named ToyVpn. I ran the application but I didn't know what data I had to give in the form displayed by that application. Considering I have a VPN server with an IP address (say 10.162.1.2), what do I need to do in that application so this app work ?
If I try to use a public VPN server, what do I need to do?
I downloaded OpenVPN source code from GIT/ics-openvpn and I compiled it and ran on my ICS device, but I didn't know how to configure the data that needs to be entered.
Please can somebody provide the exact way to use this app ?
I want to know how to setup a VPN connection in Android using an application?
The Android SDK comes bundled with a sample; see ToyVpn in the android-16 samples directory. Also consult the documentation for VpnService and VpnService.Builder.
I came across a sample code namely ToyVpn.I ran the application but i dont know what datas i need to give in the form shown by that application, Consider iam having a VPN server with ip-address (say 10.162.1.2), What i need to do in that application to make that app work .
Your VPN will need to create a new socket, protect the socket from being routed back into the VPN using VpnService.protect(Socket), and connect the socket to 10.162.1.2. Having set up a tunnel connection to the VPN server, you should proceed to writing the input stream of the VpnService's interface into the tunnel's output stream, and in turn write the tunnel response back into the interface output stream.
If i try to use any public VPN server, What i need to do?
There is no standard mechanism in place for setting up a connection to a VPN server. ToyVpn simply communicates over a socket using raw TCP packets. You can either implement an existing protocol (see RFC 4026) like OpenVPN has done or write something yourself.

How to create an adhoc network between laptops in java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to create an adhoc between labtops were they will communicate using wireless communication. I will use java for this but still I do not know how to start..
I think I'll have to use sockets for the connections right? How will a laptop notice other laptops in its local network or the other way around? Do i need a server to handle the communication between laptops? Another thing, how to broadcast a message from one laptop to other laptops in the network? Please reply as soon as you can. Any help will be appreciated. Thanks in advance.
Generally changing network settings is both a privileged and system-specific task, so it's not ordinarily something that java applications should or would be permitted to do.
That's not to say it's necessarily impossible. For example, if you can figure out how to create and/or join a network from the command line, you may be able to issue those commands if the JVM permits it and you can somehow secure the necessary permissions. On a linux machine, this would probably be some combination of iwconfig and/or ifconfig usage - but normally requires root.
One you have a network up then you can deal with socket type traffic over it - an area where java is far more at home, and one that is often possible without special privileges, at least as far as the operating system is concerned.
Can you restate the problem:
Do you want to create appropriate low level settings for the "hardware" to set up ad-hoc WLAN
This is what the answers above try to handle...
You have two devices already authenticated in a WLAN that should be able to mutually detect services (in the way UPnP is designed)?
In this case you have some other tools available. You start with advertising a service using somthing like Zeroconf (Bonjour, available as jmDNS in open source). The other party is able to look up the service using jmDNS again. This works using UDP.
Once found you can establish direct IP communication as usual.
To broadcast information you have to program sockets on UDP level. If you don't want to go to greatest detail, there are also frameworks around (Apache MINA).
If u have to use java, I would advice u to have a look at the JANE, Java Ad Hoc Network Development Environment.
Good luck.
Is this academic? If so, try using simulators first. There are a lot of good simulators available for free (For eg. NS2, glomosim). It is a good place to start for proof of concept. These simulators have good mobile communication protocols (including mobile adhoc setup). You will not have to deal with nitty-gritty details and concentrate more on your application.

Categories

Resources