-4

I'm new to Openfire server so I'm not very sure on how to use it. I'm trying to connect the server to an Android application which I had found on the web :

From the code , there is a host , port , username and password. I tried input the following: host : 127.0.0.1 port : 5222

However , the result of the application had failed which stated the error message that the server was not connected.

I had found on the web (Why can't I connect to the openfire server?) which the methods stated to edit the openfire.xml file. I had edited the file and the host number from the code into my ip address and it manage to work.

I'm just wondering why doesn't the original server ip address (127.0.0.1) not able to work while my ip address able to work?I'm also not sure if this problem only applicable to me alone.

Currently , I'm using emulator from Eclipse to run the application. But i believe in the future I will faced this issue again as I doubt using my own IP address able to work in the phone.

Edited : I understand that Emulator needed network connection to connect to Openfire server which is why I have to change.

Currently my doubt is how to change the code to such that my application is able to connect and send messages via Openfire on mobile phone devices ? I had tried searching solution but I couldn't find any. One solution I found in this website was to put the connection part of the code in AsyncTask. Is this true ?

Community
  • 1
  • 1

1 Answers1

0

I'm just wondering why doesn't the original server ip address (127.0.0.1) not able to work while my ip address able to work?

127.0.0.1 isn't the server's real IP address. It means localhost, which means whichever computer the code is running on. In other words, the Android application would try to connect to the server on the Android device, but I don't think your OpenFire server is running on the Android device, is it?

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • Hi Robin! Thanks for helping. But I'm quite confuse of 127.0.0.1 not being the server's real IP address. The application I'm doing is trying to connect to Openfire Server which allows 2 devices to communicate with one another. My worries now is that if I install the application into the phones , I'm afraid it will not work as I'm using my own ip address as the connection. – user3162777 Jan 06 '14 at 01:18
  • How to deal with changing IP of the server? – Krupal Shah Nov 12 '14 at 18:41