Momo
Momo

Reputation: 369

Smack's XMPP over TCP connection stops after the main() method returns

I started using the Ignite Smack API 4.1.6 for creating a basic XMPP over TCP client. I use the smack-tcp and smack-java7 API. The code is pretty basic.

//In a main

//Create XMPPTCPConnectionConfiguration
//Create XMPPTCPConnection using the configuration
//connect and login

After logged in successfully and sent the first presence message, it seems that at the time the code into the main finishes executing the connection is shut down.

I expected that the API would created a TCP socket connection that stays alive into a separate thread, but it seems that it's not the behaviour I get.

Any suggestions?

Thanks.

Upvotes: 1

Views: 170

Answers (1)

Flow
Flow

Reputation: 24083

The JVM will exists if the main() method exists and if there a only daemon treads left. Smack uses daemon threads exclusively. Thus your JVM exists.

See also if main method completes the execution, what happens to any long running thread?

Upvotes: 1

Related Questions