我正在使用openfire从Android客户端发送聊天按摩我从火花客户端获得按摩但是无法向按摩客户端发送按摩我收到以下错误:
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(Unknown Source)
at javax.naming.directory.InitialDirContext.getAttributes(Unknown Source)
at org.jivesoftware.openfire.net.DNSUtil.srvLookup(DNSUtil.java:192)
at org.jivesoftware.openfire.net.DNSUtil.resolveXMPPDomain(DNSUtil.java:124)
org.jivesoftware.openfire.session.LocalOutgoingServerSession.authenticateDomain
(LocalOutgoin gServerSession.java:167)
org.jivesoftware.openfire.server.OutgoingSessionPromise$
PacketsProcessor.sendPacket(OutgoingSessionPromise.java:261)
at org.jivesoftware.openfire.server.OutgoingSessionPromise$
PacketsProcessor.run(OutgoingSessionPromise.java:238)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2014.11.20 12:35:36 org.jivesoftware.openfire.net.DNSUtil -
No SRV record found for: _jabber._tcp.test
javax.naming.NameNotFoundException: DNS name not found [response code 3];
remaining name '_jabber._tcp.test'
at com.sun.jndi.dns.DnsClient.checkResponseCode(Unknown Source)
at com.sun.jndi.dns.DnsClient.isMatchResponse(Unknown Source)
at com.sun.jndi.dns.DnsClient.doUdpQuery(Unknown Source)
at com.sun.jndi.dns.DnsClient.query(Unknown Source)
at com.sun.jndi.dns.Resolver.query(Unknown Source)
at com.sun.jndi.dns.DnsContext.c_getAttributes(Unknown Source)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(Unknown Source)
at javax.naming.directory.InitialDirContext.getAttributes(Unknown Source)
at org.jivesoftware.openfire.net.DNSUtil.srvLookup(DNSUtil.java:192)
at org.jivesoftware.openfire.net.DNSUtil.resolveXMPPDomain(DNSUtil.java:126)
org.jivesoftware.openfire.session.LocalOutgoingServerSession.
createOutgoingSession(LocalOutgoingServerSession.java:270)
atorg.jivesoftware.openfire.session.LocalOutgoingServerSession.
authenticateDomain(LocalOutgoingServerSession.java:167)
at org.jivesoftware.openfire.server.OutgoingSessionPromise$PacketsProcessor.
sendPacket(OutgoingSessionPromise.java:261)
atorg.jivesoftware.openfire.server.OutgoingSessionPromise$
PacketsProcessor.run(OutgoingSessionPromise.java:238)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2014.11.20 12:35:36 org.jivesoftware.openfire.session.
LocalOutgoingServerSession - LocalOutgoingServerSession: OS - Trying to connect to
test:5269(DNS lookup: test:5269)
2014.11.20 12:35:38 org.jivesoftware.openfire.nio.
ClientConnectionHandler - [/######:1242] Filtered Write:
org.apache.mina.filter.support.SSLHandler@1d53274
org.jivesoftware.openfire.nio.ClientConnectionHandler -
org.jivesoftware.openfire.nio.ClientConnectionHandler -
Wrap res:Status = OK HandshakeStatus = NOT_HANDSHAKING
bytesConsumed = 190 bytesProduced = 211
org.apache.mina.filter.executor.ExecutorFilter - Launching thread for
org.jivesoftware.openfire.server.OutgoingSessionPromise -
OutgoingSessionPromise: Error sending packet to *****server:
<message id="zg34L-9" to="test" type="chat" from="demo@localhost/Smack">
<body>hi</body>
</message>
java.lang.Exception: Failed to create connection to remote server
at org.jivesoftware.openfire.server.OutgoingSessionPromise$PacketsProcessor.
sendPacket(Outgoing SessionPromise.java:274)
at org.jivesoftware.openfire.server.OutgoingSessionPromise$
PacketsProcessor.run(OutgoingSession Promise.java:238)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
org.apache.mina.filter.executor.ExecutorFilter - Exiting since queue is empty for
public class XMPPChatDemoActivity extends Activity {
public static final String HOST = "#########";
public static final int PORT = 5222;
public static final String USERNAME = "demo@servername";
public static final String PASSWORD = "demo";
public static final String SERVICE = "servername";
private XMPPConnection connection;
private ArrayList<String> messages = new ArrayList<String>();
private Handler mHandler = new Handler();
private EditText recipient;
private EditText textMessage;
private ListView listview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
recipient = (EditText) this.findViewById(R.id.toET);
textMessage = (EditText) this.findViewById(R.id.chatET);
listview = (ListView) this.findViewById(R.id.listMessages);
setListAdapter();
// Set a listener to send a chat text message
Button send = (Button) this.findViewById(R.id.sendBtn);
send.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String to = recipient.getText().toString();
String text = textMessage.getText().toString();
Message msg = new Message(to, Message.Type.chat);
msg.setBody(text);
if (connection != null) {
connection.sendPacket(msg);
messages.add(connection.getUser() + ":");
messages.add(text);
setListAdapter();
Roster roster = connection.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries) {
Log.d("XMPPChatDemoActivity",
"--------------------------------------");
Log.d("XMPPChatDemoActivity", "RosterEntry " + entry);
Log.d("XMPPChatDemoActivity",
"User: " + entry.getUser());
Log.d("XMPPChatDemoActivity",
"Name: " + entry.getName());
Log.d("XMPPChatDemoActivity",
"Status: " + entry.getStatus());
Log.d("XMPPChatDemoActivity",
"Type: " + entry.getType());
Presence entryPresence = roster.getPresence(entry
.getUser());
Log.d("XMPPChatDemoActivity", "Presence Status: "
+ entryPresence.getStatus());
Log.d("XMPPChatDemoActivity", "Presence Type: "
+ entryPresence.getType());
Presence.Type type = entryPresence.getType();
if (type == Presence.Type.available)
Log.d("XMPPChatDemoActivity", "Presence AVIALABLE");
Log.d("XMPPChatDemoActivity", "Presence : "
+ entryPresence);
// Toast.makeText(XMPPChatDemoActivity.this,
// "gettting user", Toast.LENGTH_SHORT).show();
}
} else{
Log.i("XMPPChatDemoActivity", "no massage send");
Log.e("XMPPChatDemoActivity", "Failed to log in as "
+ connection.getUser());
}
}
});
connect();
}
/**
* Called by Settings dialog when a connection is establised with the XMPP
* server
*
* @param connection
*/
public void setConnection(XMPPConnection connection) {
this.connection = connection;
if (connection != null) {
// Add a packet listener to get messages sent to us
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
connection.addPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
Message message = (Message) packet;
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message
.getFrom());
Log.i("XMPPChatDemoActivity", "Text Recieved "
+ message.getBody() + " from " + fromName);
messages.add(fromName + ":");
messages.add(message.getBody());
// Add the incoming message to the list view
mHandler.post(new Runnable() {
public void run() {
setListAdapter();
}
});
}
}
}, filter);
}
}
private void setListAdapter() {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listitem, messages);
listview.setAdapter(adapter);
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (connection != null)
connection.disconnect();
} catch (Exception e) {
}
}
public void connect() {
final ProgressDialog dialog = ProgressDialog.show(this,
"Connecting...", "Please wait...", false);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
// Create a connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
HOST, PORT, SERVICE);
XMPPConnection connection = new XMPPConnection(connConfig);
try {
connection.connect();
Log.i("XMPPChatDemoActivity",
"Connected to " + connection.getHost());
// Toast.makeText(XMPPChatDemoActivity.this,
// "Connected to server", Toast.LENGTH_SHORT).show();
} catch (XMPPException ex) {
Log.e("XMPPChatDemoActivity", "Failed to connect to "
+ connection.getHost());
Log.e("XMPPChatDemoActivity", ex.toString());
setConnection(null);
// Toast.makeText(XMPPChatDemoActivity.this,
// "Failed to connect ", Toast.LENGTH_SHORT).show();
}
try {
// SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.login(USERNAME, PASSWORD);
Log.i("XMPPChatDemoActivity",
"Logged in as " + connection.getUser());
// Set the status to available
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
setConnection(connection);
Roster roster = connection.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries) {
Log.d("XMPPChatDemoActivity",
"--------------------------------------");
Log.d("XMPPChatDemoActivity", "RosterEntry " + entry);
Log.d("XMPPChatDemoActivity",
"User: " + entry.getUser());
Log.d("XMPPChatDemoActivity",
"Name: " + entry.getName());
Log.d("XMPPChatDemoActivity",
"Status: " + entry.getStatus());
Log.d("XMPPChatDemoActivity",
"Type: " + entry.getType());
Presence entryPresence = roster.getPresence(entry
.getUser());
Log.d("XMPPChatDemoActivity", "Presence Status: "
+ entryPresence.getStatus());
Log.d("XMPPChatDemoActivity", "Presence Type: "
+ entryPresence.getType());
Presence.Type type = entryPresence.getType();
if (type == Presence.Type.available)
Log.d("XMPPChatDemoActivity", "Presence AVIALABLE");
Log.d("XMPPChatDemoActivity", "Presence : "
+ entryPresence);
// Toast.makeText(XMPPChatDemoActivity.this,
// "gettting user", Toast.LENGTH_SHORT).show();
}
} catch (XMPPException ex) {
Log.e("XMPPChatDemoActivity", "Failed to log in as "
+ USERNAME);
Log.e("XMPPChatDemoActivity", ex.toString());
setConnection(null);
}
dialog.dismiss();
}
});
t.start();
dialog.show();
}
}
我正在使用嵌入式openfire pls建议我对此有任何想法
答案 0 :(得分:1)
您忘记了要向其发送邮件的用户的主机部分。您希望将其发送到test@localhost
,通过将其发送到test
,服务器开始寻找另一个主机名为test
的服务器(失败)。