Why can't I connect to the openfire server?

无人久伴 提交于 2019-12-18 07:16:38

问题


I'm having a little bit of trouble trying to connect to Openfire (which I've installed on my computer) while 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 debugging or running, there's an error of some sort in the connect() line.

XMPPError connecting to localhost:5222.: remote-server-error(502) XMPPError connecting to localhost:5222. -- caused by: java.net.SocketException: Permission denied.

I've tried switching the host name to "localhost", and it didn't work either.

I have no experience in this XMPP business so I guess it's a common newbie problem or something of the sort...

What might be the problem? How can I fix this so the connection will be successful?


回答1:


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

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

Make sure that you haven't done the same mistake.




回答2:


I have Same problem .... but i resolved this issue at my end using following steps :::

1) Firstly checked Internet permission

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

2) Then open the openfire.xml file from C:\Openfire\conf (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 helpful for you....




回答3:


i had the same problem, i followed these steps to solve it:

  1. disable your firewall first

  2. use your the IP address of your server openfire




回答4:


Use host as localhost if you are using a device. If you are using an emulator, use ip address (192.168.1.2 or whatever) in the configuration step (line 1 of the given code)



来源:https://stackoverflow.com/questions/6804236/why-cant-i-connect-to-the-openfire-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!