问题
I want to create my own XMPP android client . So I begane with the samsung tutorial which interface itself with gmail and that you can find here : http://developer.samsung.com/android/technical-docs/Building-a-Chat-Application
It worked like a charm. Now I tryed to setup this client for working with my openfire server.
For this I converted the folowing lines:
public static final String HOST = "My public ip(82.65....)";
public static final int PORT = 5222;
public static final String SERVICE = "xmppclient.talkative.com";
public static final String USERNAME = "test";
public static final String PASSWORD = "test";
Actually we find back these variable in the connection setter:
ConnectionConfiguration connConfig = new ConnectionConfiguration(
HOST, PORT, SERVICE);
XMPPConnection connection = new XMPPConnection(connConfig);
Finally I never manage to connect to the server and I always get the following error
03-27 00:18:00.660: E/XMPPChatDemoActivity(29942): Failed to connect to 81.65.**.***:5222.
03-27 00:18:00.663: E/XMPPChatDemoActivity(29942): XMPPError connecting to 81.65.**.***:5222.: remote-server-error(502) XMPPError connecting to 81.65.**.***:5222.
This seems to be very simple but still I cannot get the right connection .
I precise that I have the good INTERNET conf in my Manifest.
If anyone has a clue it would be really usefull .
Thanks
回答1:
- SERVICE - is the "Server name" of your openfire instance, it should be
talkative.com
. - HOST - it is a public DNS name of the server machine, e.g.
xmppclient.talkative.com
- PORT - 5222 in the default setup, check this port should be open to public network.
If you have access to DNS configuration of talkative.com, you can add SRV record
_xmpp-server._tcp.talkative.com
pointing to xmppclient.talkative.com:5269
(if you want to add your server in federation with other public XMPP servers) and
_xmpp-client._tcp.talkative.com
pointing to xmppclient.talkative.com:5222
.
This is a perfect setup, in which case Smack ConnectionConfiguration requires only
ConnectionConfiguration connConfig = new ConnectionConfiguration(
"talkative.com");
And all other parameters it will detect automatically via DNS.
回答2:
just use two following parameters to connect from server
public static final String HOST = "192.168.1.124";
public static final int PORT =5222;
After this further process will start. Host will be the ipaddress of your system where you installed openfire server but condition is you must be in same network Ipaddress, port defautly be 5222.
来源:https://stackoverflow.com/questions/22675177/trying-to-reach-my-openfire-server-through-my-android-client