Hi,
I’'m using the gateway plug in 1.1.0 beta 1, openfire 3.3 and smack 3.0.1 to talk from my Java code to the openfire server.
I’'m accepting people signing into their MSN / ICQ / AIM accounts via my mini system. When they first enter their details I call the method below - this method attempts to register with the transport and then assuming that works without a hitch it will set the presence on the transport to force the login. (it is based heavily on the PoC code in the ignite code repository).
public boolean registerWithTransport(Transport transport, String username, String password) {
try {
// These filters and collectors are needed when processing
// packets to and from the transports
PacketCollector regAck = connection.createPacketCollector(new PacketTypeFilter(Registration.class));
AndFilter msgFromTransport = new AndFilter();
msgFromTransport.addFilter(new PacketTypeFilter(Message.class));
msgFromTransport.addFilter(new FromMatchesFilter(transport.getJid()));
AndFilter subRequestFromTransport = new AndFilter();
subRequestFromTransport.addFilter(new PacketTypeFilter(Presence.class));
subRequestFromTransport.addFilter(new FromMatchesFilter(transport.getJid()));
PacketCollector msgAck = connection.createPacketCollector(msgFromTransport);
PacketCollector subReq = connection.createPacketCollector(subRequestFromTransport);
// With these blocking collectors in place we’'ll now process the registration
// This block starts the conversation with the transport
Registration conv1 = new Registration();
conv1.setType(IQ.Type.GET);
conv1.setTo(transport.getJid());
connection.sendPacket(conv1);
// When the transport has acknowledge this or a timeout has occured we continue
Registration regRep = (Registration) regAck.nextResult(5000);
if ( regRep == null ) {
// if the response was null it means an ack didn’'t come in
// within the 5second max.
return false;
}
// As we got a response we’'ll now register our details with the server
Registration regReq = new Registration();
regReq.setType(IQ.Type.SET);
regReq.setTo(transport.getJid());
DataForm registerDetails = new DataForm(“submit”);
FormField transUser = new FormField(“username”);
FormField transPass = new FormField(“password”);
transUser.addValue(username);
transPass.addValue(password);
registerDetails.addField(transUser);
registerDetails.addField(transPass);
regReq.addExtension(registerDetails);
connection.sendPacket(regReq);
Message response = (Message) msgAck.nextResult(5000);
if ( response == null || ( response != null && response.getType() != Message.Type.error ) ) {
Presence goOnline = new Presence(Presence.Type.available);
goOnline.setTo(transport.getJid());
connection.sendPacket(goOnline);
clientRoster.addTransport(transport.getJid());
return true;
}
} catch (XMPPException e) {
//Add transport failed
}
return false;
}
Now the issue - in the case of ICQ and MSN this method provides a 98% success rate. In the case of AIM it only succeeds 39% of the time.
I need to qualify that statement; by succeed I mean it returns true, and then the person can see their contacts from that transport.
What is likely to be the issue here? I think a possiblity is that the msgAck.nextResult(5000) is not returning within the 5seconds and is resulting in me assuming the registration was successful, when in reality AOL hasn’'t responded just yet and actually the provided credentials are incorrect. Assuming this is the case what is a realistic timespan to put in this timeout?
Before I put the timeout in I was blocking until a response came through - however I realized that a response didn’'t come through in a number of cases (this was with a pre 1.0 gateway plug in). This seemed to fly against what the gateway XEP said would happen. Can someone confirm whether upon successful registration the gateway will return a success message?
Which log files will be reporting the bad credentials? What am I looking for in those log files. Will there be anything in the log file if I’'m timing out and continuing my code flow after the 5seconds?
Help/Hints much appreciated