Introduction and deployment of openfire Based on XMPP openfire smack [1]

Source: Internet
Author: User
Tags ldap domain server
Preface

Openfire + spark + smack can be considered for Java instant messaging solutions. Of course there are other options.

Openfire is an instant messaging server version based on the jabber protocol (XMPP). We recommend that you use version 3.8.1, which is the latest version and can find the downloaded source code online.

The instant messaging client can use spark2.6.3, which is currently the latest version of release. After testing, it is found that the previous version supports video and MSN gateway supports problems, therefore, openfire3.8.1 + spark2.6.3 is the most appropriate choice.

Smack is the real-time communication client programming library. Currently, I have tested that smack APIs are used in JSP to send messages to openfire registered users, and the listener can receive response messages from this user.

Smack can also be used to send messages to MSN users and QQ users. There are many examples of sending messages to Gtalk users. This is to be studied later. At least currently, you can send messages to spark through a program. Internal LAN applications can solve the problem of system interaction with users, and even implement automatic response robots.

Spark supports chat, voice, video, conference, File Sending and receiving, screenshots, and MSN connections.

At the same time, the Android mobile and Web end also have corresponding programming library support, which will be updated in later chapters for you, next, we should first give some necessary explanations on several key technical links.

 

1. What is XMPP?

XMPP (Extensible messaging and presence Protocol) is a protocol for sending and receiving messages, but the messages sent by this Protocol are neither binary nor strings, but XML. Extensible is talking about it because XML is used as the intermediary for message transmission. The predecessor of XMPP is jabber, an open-source network instant communication protocol. XMPP has been standardized by IETF International Standards Organization.

2. Im

Instant Messenger and timely communication software are QQ, MSN Messenger, and Gtalk. Gtalk is an implementation based on the XMPP protocol, while others are not. At present, Im is an inevitable tool for almost every netman. There are some enterprise-level IM applications in large foreign enterprises, but its commercial value has not been fully realized yet. Imagine that XMPP is a public protocol, so every enterprise can use it to develop im suitable for its own business and improve its production efficiency; or even, you can also integrate this communication software in online games so that you can not only chat while playing, but also develop IM applications suitable for the game itself, such as some key game scenario reminder functions, team speech communication can be implemented based on IM.

3. Spark, smack, and openfire

There are always a lot of interesting things in the open-source world. These three are combined into a complete XMPP im implementation. Including the implementation of the server -- openfire, client -- spark, and XMPP transmission protocols -- smack (Remember, XMPP is a protocol that needs to be implemented, smack plays this role ). All three are implemented based on the Java language.

Spark provides a basic implementation of the client and provides a good plug-in architecture. This is a good news for developers. I strongly recommend that you use plug-ins to implement your new functions, instead of modifying the source code. This will benefit your project architecture and minimize the impact of the original project.

Openfire is an implementation of an IM Server Based on XMPP protocol. Although two users can send messages in point-to-point mode after connection, however, you still need to connect to the server to obtain some connection information and communication information. Therefore, the server must be implemented. Openfire also provides some basic functions, but it is really basic! Fortunately, it also provides plug-in extensions. Like spark, it is strongly recommended to use plug-in extensions to add new features, rather than modifying the source code of others.

Smack is a Java implementation of XMPP protocol and provides a set of scalable APIs. However, sometimes you still have to use your own custom XML file content to implement your own functions.

 

Shows the relationship between the three:

Spark provides a basic implementation of the client and provides a good plug-in architecture. This is a good news for developers. I strongly recommend that you use plug-ins to implement your new functions, instead of modifying the source code. This will benefit your project architecture and minimize the impact of the original project.

Openfire is an implementation of an IM Server Based on XMPP protocol. Although two users can send messages in point-to-point mode after connection, however, you still need to connect to the server to obtain some connection information and communication information. Therefore, the server must be implemented. Openfire also provides some basic functions, but it is really basic! Fortunately, it also provides plug-in extensions, like spark.

Smack is an XMPP Java implementation that provides a set of scalable APIs. However, in some cases, you still have to use your own custom XML file content to implement your own functions.

4. Install openfire3.8.1

To use openfire, You need to configure the machine domain name. If the domain server is not installed in the LAN, You need to manually configure the domain name for the machine, open the c: \ windows \ system32 \ drivers \ etc \ hosts file, and add a new line:
127.0.0.1 csdn.shimiso.com)
If other machines use the domain name to access openfire, you also need to specify the IP address corresponding to bzwang.tzsoft.com in C: \ windows \ system32 \ drivers \ etc \ hosts. Assume that the Host IP address on which openfire is installed is 192.168.1.10, A new line should be added to the hosts file:
192.168.1.10 csdn.shimiso.com
In this way, specify the host domain name. We recommend that you configure the static IP address for the machine where openfire is installed to avoid IP address changes.

Select Simplified Chinese as the language. For more information, see:

Follow the prompts to install openfire. Then, the following page is displayed:

Click "launch admin". The following page is displayed. The page connection is http: // 127.0.0.1: 9090/Setup/index. jsp.

Select Chinese (simplified) and click "continue": (if the following page shows English, please refresh the page or click launch admin again)

The domain on this page is the machine name by default. Please change it to the domain name set at the beginning, for example, csdn.shimiso.com, and then click Continue ):

The first option on this page is standard database connection. Do not select an Embedded Database (Embedded Database, HSQLDB database for the embedded database, and do not select this option for the production environment ), click "continue ":

Here I am using the MySQL database. It is best to use more than 5.0 according to the official requirements. Make sure there is an inventory named openfire. After the configuration, continue.

This page is used to configure whether to use LDAP. We do not configure LDAP now, so select default as the default value. Click continue:

Enter the email address and confirm the password, and then click Continue: Wait about 30 seconds until the installation and configuration are complete. Open
Http: // 127.0.0.1: 9090/login. jsp
Logon Management page

Add a user to the user/group.

5. Client configuration and debugging

Here I did not use the official spark client, but used Pandi and Ruyi Tong. The configuration is as follows:

Chat Demonstration:

 

From the above chat records, we found that the full names of all user IDs are: User Name @ domain name/resource name. This is the jid we usually talk about in XMPP protocol, that is, Jabber ID, it is the general name of an XMPP protocol account system. This parameter is often used later when we use the smack programming library to debug interfaces.

 

PS: This course is original. If there are similarities, it is a coincidence that we welcome various forms of technical exchange, joint discussion and Axe.

 

 

 

Reprint please indicate the source http://blog.csdn.net/shimiso

Welcome to our technical exchange group: 173711587

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.