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 ?
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?
Related
I'm trying to connect my real android device to local server.
So at the beginning I connect all devices to 1 network via Wi-Fi.
Next step is copy IPv4 from ipconfig.
Now I'm entering myIpv4:8080 into browser in my android Device and I get ERR_CONNECTION_TIMED_OUT.
I forgot something ? What can be wrong ?
I should get JSON object like in PC browser.
can you check your web server is listening on a 0.0.0.0 or just localhost?
Localhost is a loop back IP for every machine. If a webserver is listening to Localhost interface, it only accepts network request from the machine it runs on. Your Android request may be ignored.
as you can read in title I'm making a super simple IOT (Not really)
and
using a esp8266 and want to make it connect to my home wifi network and make a communication between a android app and the module (android app connects to home wifi)
Note : Iam Using CODE VISION AVR
you may say :
Why not directly connect to ESP when its on Server Mode?
that's fine cause when ESP is server "he" can set ip for him self so
ip will be always same BUT I want it to connect to home wifi
-
Why you wont connect with IP ?
you cant find the module ip easily because its given by Wifi
-
Find ESP ip using IP scanner
Its not possible cause it changes every time and user have to change
IP every time in android app AND my app cant scann every time it want
to connect to a single device its so dumb...
-
Do a Static Ip for ESP !
well that's not possible too because maybe that IP was taken by
someone before ESP send static IP AT command ! + if IP wasent taken it may taken after Home Wifi Restarts !
Sorry for bad English :X
You can use software serial to configure esp8266 from arduino. You need to know the setup circuit perfectly. Keep it in mind that esp8266 operates on 3.3V where arduino gives 5V output. The most important thing is to send AT commands to esp8266. You can use the following command to connect with your wifi.
AT+CWJAP="Your_WiFi","password"
If you need to see the ip address of esp8266, you can use this command.
AT+CIFSR
If you want to set static ip to esp8266 , then you can try this one.
AT+CIPSTA="ip module","ip gateway","subnet mask"
Use mDNS responder:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server.ino
This way you would be able to connect to ESP8266 via hardcoded url like http://esp8266.local.
I deployed my app on Heroku. It is a simple app that will throw back the message sent from its client version (running on my PC) back to the client. My server app prints the IP address of the machine it's running on so I can connect to it from my client . I do get to see the IP address of Heroku machine when I deploy and run it. However, I am not able to connect to it from my client version using that IP address(Connection timed out) . I have allowed the port I am using in my firewalls. I don't understand what I am doing wrong .
Pls help me solve it.
If you need to see my code let me know ( the app works fine locally on different terminals so I don't think it has a problem).
Your Heroku dyno (an isolated server) is behind a router. You can't use the IP address to connect to it.
Instead, you the URL https://[appname].herokuapp.com where "[appname]" is the name of your app.
You can also run heroku open from the command line.
I'm building an android application that should connect to servlet called "Login" in order to verify the user name and the password. It works fine en genyMotion emulator when I use :
http://192.168.1.100:8081/Android/Login
. But , when I try to connect using my real device , I got time out connection error. I'm using "my wifi router 3.0" to make my laptop hosting my phone. I even tried
http://192.168.23.1:8081/Android/Login
but still didn't work.
Here's my ipconfig :
This seems like a firewall issue on your system.
Emulator is able to connect because the connection is originating from localhost (same system). However the connection from real device is considered as incoming connection from remote host.
By default windows does not allow any incoming connection from remote host. You change this in firewall setting to allow incoming connections on port 8081.
My activity needs to communicate with a java server located on my dev machine. Actually, using the emulator, I can access the server socket via the special 10.0.2.2 address. Now I'd like to test my app on my phone connected via usb, but it seems like I can't use 10.0.2.2 to access my dev machine localhost anymore.
Naturally using a wifi router and a proper lan addressing does the trick, but I need to use usb connection instead. Any hint ?
edit:
Just added different scenarios to let everyone understand better:
1. Emulator-based scenario:
standard java server running on my pc #localhost:15000
android java client running on my emulator.
When the android app needs to contact the server it uses 10.0.2.2:15000 like specified here.
Everything works fine.
2. Proper wifi scenario with physical connected device:
standard java server running on my pc #192.168.1.10:15000.
android java client running on my device with 192.168.1.11 address assigned.
When the android app needs to contact the server it uses 192.168.1.10:15000 and everything works fine too.
3. Desired scenario:
standard java server running on my pc #localhost:15000.
android java client running on my device connected via usb cable. No network is active.
When the android app needs to contact the server it tries to connect to 10.0.2.2:15000 but instead an exception is thrown (Network unreachable). It seems like special address 10.0.2.2 works only for emulator instances.
I just wonder if in the adb/adt suite there's a way to access pc address from the device connected via usb cable.
I hope it's a bit more clear now.
Thanks.
It seems like there's no way to let scenario #3 work properly, because usb connection is not a real network connection and there's no ip associated to it by the phone.
Actually my solution is to use an ad-hoc wifi connection between my phone and my pc. This scenario is similar to #2, but without router or dhcp. Unfortunately my Hero can't handle ad-hoc connections natively because of this issue. So I had to root my device and to change manually some config script. I hope functionality like this can be available in next releases.
You can setup a connect to your phone over USB from your dev pc, but you have to adb forward. However, I don't think you can route the otherway around over usb: setting up a connection from the phone to the pc.
You could have your pc connect to the phone and check which IP it has.
While thinking about it, I realized, using adb forward you have to use localhost as your host, so maybe you could also do this on your phone: adb forward the port you want to use and on your phone, connect to that port on localhost.