public static BrowseIQ retrieveBrowseRequest(XMPPConnection conn, String to) throws XMPPException {
BrowseIQ iq = new BrowseIQ();
iq.setType(IQ.Type.GET);
iq.setTo(to);
PacketCollector collector =
conn.createPacketCollector(new PacketIDFilter(iq.getPacketID()));
conn.sendPacket(iq);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());