user3236289
user3236289

Reputation:

XMPP JID seems like always null

I use XMPP to build a chat application. While attempting to log in, I see that my JID instance is always null. I thus can connect the server but I cannot properly authenticate.

self.xmppStream.myJID = [XMPPJID jidWithString:@"efeuser"];
NSLog(@"%@",self.xmppStream.myJID.user);

It logs myJID as null.

I also tried to create a new user on Openfire with register packet, but the user JID is also null.

 <iq xmlns="jabber:client" type="error" to="bowerchat.com/3df1adfc">
  <query xmlns="jabber:iq:register">
   <username/>
   <password>efe1414</password>
  </query>
  <error code="500" type="wait">
   <internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  </error>
 </iq>

Upvotes: 0

Views: 240

Answers (1)

xnyhps
xnyhps

Reputation: 3316

JIDs can be of two forms:

[email protected]
example.com

If they include an @, then the part before the @ is the userpart. But the userpart may also be left out, as it is in the second example. This is usually used to address the host directly.

self.xmppStream.myJID = [XMPPJID jidWithString:@"efeuser"];

This creates a new JID efeuser with no userpart. This means:

NSLog(@"%@",self.xmppStream.myJID.user);

Prints (null) correctly, as there is no userpart.

Upvotes: 1

Related Questions