Project

General

Profile

Tigase server communicating with mongo DB installation

Aniketh R Jain
Added over 1 year ago

Hello,

I have never worked with XMPP. I am implementing chat in my social media application and I need to have the Tigase server talking to a mongoDB. I didnt find any proper tutorial for the same. As I dont have much knowledge in the xmpp domain, I need help as I need to do it from scratch. My current service to perform other social media application tasks is just a java servlet on tomcat test server. Please guide me on this.


Replies (8)

Added by Wojciech Kapcia TigaseTeam over 1 year ago

You need a properly configured Tigase server - you can use various methods to achieve that - we even offer web installer which allows you selecting needed component and selecting database which will be used (including MongoDB). Afterwards you only need to start the server and voila. Please refer to documentations of your Tiagse version available on http://docs.tigase.org/#tigase-server for more details.

Added by Aniketh R Jain over 1 year ago

Thanks a lot for replying. :-) I have done the setup to some extent following the documentation but I still don't know about configuring it efficiently. Hence for now I will start using.

Another doubt I have is how do I use the certificates. I get an error when I try connecting to tigase server using Smack API stating the PKIX path building failed and unable to find valid certificate at the path of the requested target.

Please help me if you can on the certificate part. It would be very helpful for me. As of now I can connect successfully to the tigase server when the security mode is disabled.

Also, where can I find the settings like my XMPP domain name, hostname settings inside tigase.

Added by Wojciech Kapcia TigaseTeam over 1 year ago

Aniketh R Jain wrote:

Thanks a lot for replying. :-) I have done the setup to some extent following the documentation but I still don't know about configuring it efficiently. Hence for now I will start using.

Another doubt I have is how do I use the certificates. I get an error when I try connecting to tigase server using Smack API stating the PKIX path building failed and unable to find valid certificate at the path of the requested target.

Please help me if you can on the certificate part. It would be very helpful for me. As of now I can connect successfully to the tigase server when the security mode is disabled.

This is because you don't have valid certificate for your domain - you should either buy a correct certification from respectable CA (or get let's encrypt certificate) or disable certificate checking in the client application - you would still get the benefit of encryption but without validation of the server entity.

Also, where can I find the settings like my XMPP domain name, hostname settings inside tigase.

You mostly manage and configure tigase via configuration file and adding vhosts/domain is done via --vhosts= property. You can also use web AdminUI ( http://hostname:8080/admin/ )

Added by Aniketh R Jain over 1 year ago

  • Below is my init.properties
config-type=--gen-config-def
--admins = admin@localhost
--virt-hosts = localhost
--debug=server
--user-db-uri=mongodb://localhost/tigase_test
--user-db=tigase.mongodb.MongoRepository
--auth-db=tigase.mongodb.MongoRepository



muc/history-db-uri=mongodb://localhost/tigase_test
muc/history-db=tigase.mongodb.muc.MongoHistoryProvider

pubsub/pubsub-repo-url=mongodb://localhost/tigase_test
pubsub/pubsub-repo-class=tigase.mongodb.pubsub.PubSubDAOMongo

message-archive/archive-repo-uri=mongodb://localhost/tigase_test
message-archive/archive-repo-class=tigase.mongodb.archive.MongoMessageArchiveRepository
  • Below is my tigase.config
#osgiEnabled=(true|false)
#osgiEnabled=false
OSGI=true
ENC="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
DRV="-Djdbc.drivers=com.mysql.jdbc.Driver:org.postgresql.Driver:org.apache.derby.jdbc.EmbeddedDriver"
#GC="-XX:+UseBiasedLocking -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:NewRatio=2 -XX:+CMSIncrementalMode -XX:ParallelCMSThreads=2 -XX:-ReduceInitialCardMarks -XX:CMSInitiatingOccupancyFraction=70  -XX:+UseCMSInitiatingOccupancyOnly"
#EX="-XX:+OptimizeStringConcat -XX:+DoEscapeAnalysis -XX:+UseNUMA"

#GC_DEBUG=" -XX:+PrintTenuringDistribution -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -Xloggc:logs/jvm.log -verbose:gc "

#JMX_REMOTE_IP="-Djava.rmi.server.hostname=0.0.0.0"

#DNS_RESOLVER=" -Dresolver-class=tigase.util.DNSResolverDefault "
#INTERNAL_IP=" -Dtigase-primary-address=hostname.local "
#EXTERNAL_IP=" -Dtigase-secondary-address=hostname "

JAVA_HOME="C:\Program Files\Java\jdk1.8.0_112"
CLASSPATH=""
#PRODUCTION_HEAP_SETTINGS=" -Xms5G -Xmx5G " # heap memory settings must be adjusted on per deployment-base!
JAVA_OPTIONS="${GC} ${GC_DEBUG} ${EX} ${ENC} ${DRV} ${JMX_REMOTE_IP} -server ${PRODUCTION_HEAP_SETTINGS} ${DNS_RESOLVER} ${INTERNAL_IP} ${EXTERNAL_IP}  -XX:MaxDirectMemorySize=128m "
TIGASE_OPTIONS=" --property-file etc/init.properties "
  • The issue I face now is if i change the virt-hosts to something else, it tells "new.host:5222" connection error

I need to understand how do i change this host name

  • Also, the users I create get created with localhost

Below is my creation code:

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                .setUsernameAndPassword("admin", "P@ssw0rd")
                .setXmppDomain("localhost")
                .setHost("localhost")
                .setPort(5222)
                .setSecurityMode(SecurityMode.disabled)
                .build();

        System.out.println("config set");
        AbstractXMPPConnection conn =  new XMPPTCPConnection(config);
        conn.connect();

        AccountManager accountManager = AccountManager.getInstance(conn);
        accountManager.sensitiveOperationOverInsecureConnection(true);
        Localpart username = Localpart.from("test4");
        accountManager.createAccount(username, "P@ssw0rd");

Now the issue is if I change the "localhost" to match a new virt-host name, it fails.**

Added by Aniketh R Jain over 1 year ago

Also when I try the admin site i get the following error

"Firefox can’t establish a connection to the server at localhost:8080."

Added by Aniketh R Jain over 1 year ago

My installation settings were:

Configuration Chat: Default Installation

Your XMPP Domains: locals.chat

Server Administrators: admin@locals.chat

Admin Password:******

Select Database: Other...

Added by Wojciech Kapcia TigaseTeam over 1 year ago

Aniketh R Jain wrote:

  • The issue I face now is if i change the virt-hosts to something else, it tells "new.host:5222" connection error

Providing detailed error would be beneficial as it gives more information why the error occurred.

I need to understand how do i change this host name

  • Also, the users I create get created with localhost

Below is my creation code:

[...]

Now the issue is if I change the "localhost" to match a new virt-host name, it fails.**

How did you changed the @localhost@? Have you changed only domain? Have you moved the server? Please keep in mind that you have both hostname (network address where the Tigase is installed and where you want to connect) and VHost/domain - which will be handled by Tigase. One more to keep in mind is that if you simply change the domain this won't affect created users, so you would need to create account with new domain name (either directly in the database or using InBandRegistration)

As for accessing admin panel - is Tigase listening on that port?

Added by Aniketh R Jain over 1 year ago

Thank you so much for replying :-)

I have not moved my server. It's just a localhost simple installation. I am just confused where all should I change the localhost. I believe that the the mongoDB path to localhost is justified as it is just a localhost installation of Mongo as well.

If I should change my initial.properties only, where all should I change it. I tried changing it a couple of times but couldn't connect with the tigase as server as the new virtual host put wasn't listening on the port 5222.

As for getting admin panel, how can I check if my tigase listening on the port 8080.

I apologize if any of my answers are primitive in their sense.

I am really interested to use the tigase Server as it perfectly fits my probable timeline of the application.

Appreciate any and all the help given :-)

    (1-8/8)