Why can't I connect to the openfire server?

I am having trouble connecting to Openfire (which I installed on my computer) when using Smack.

ConnectionConfiguration config = new ConnectionConfiguration("shin-pc" ,5222); config.setCompressionEnabled(true); config.setSASLAuthenticationEnabled(true); XMPPConnection connection = new XMPPConnection(config); connection.connect(); connection.login("test", "test"); 

When I try to debug or run, there is some error in the connect() .

Connection of XMPPError to localhost: 5222 .: remote-server-error (502) Connection of XMPPError to localhost: 5222. - called: java.net.SocketException: Permission denied.

I tried switching the hostname to "localhost", and it didnโ€™t work either.

I have no experience in this XMPP business, so I assume this is a general problem for newbies or something like that ...

What could be the problem? How can I fix this so that the connection is successful?

+1
source share
4 answers

I just created a new project in which I need XMPP and ran into the same problem. However, I realized that this was simply because I forgot to add the Internet permission to my manifest:

 <uses-permission android:name="android.permission.INTERNET"/> 

Make sure you do not make the same mistake.

+5
source

I have the same problem .... but I solved this problem at my end using the following steps:

1) First checked access to the Internet

  <uses-permission android:name="android.permission.INTERNET"/> 

2) Then open the openfire.xml file from the C: \ Openfire \ conf directory (installation directory) and edit the file

  <network> <interface>Your IP Address(192.168.0.1)</interface> </network> 

and save the file and start the openfire server. I think it will be useful for you ....

+3
source

I had the same problem, I followed these steps to solve this problem:

  • disable the firewall first

  • use your IP address of your openfire server

+1
source

Use host as localhost if you are using a device. If you are using an emulator, use the ip-address (192.168.1.2 or something else) at the configuration stage (line 1 of this code)

0
source

All Articles