IOS XMPPFramework registerWithPassword ERROR

I have a problem with the XMPP-Framework for iOS. Each time I run the registerWithPassword method, I get an error message:

"Domain Error = XMPPStreamErrorDomain Code = 1" Wait while the stream is connected. "UserInfo = 0xad7c300 {NSLocalizedDescription = Wait until the stream is connected.}"

In my code, the following steps:

  -(void)createUserWithUsername:(NSString*)name andPW:(NSString*)pw{ [self setupStream]; NSLog(@"name: %@ ",name); NSString *nameFor = name; [self disconnect]; NSString *jidBenutzer = [NSString stringWithFormat:@"%@@my-Server.com",nameFor]; NSError *error = nil; NSError * err = nil; NSLog(@"jabberid : %@",jidBenutzer); XMPPJID *jid = [XMPPJID jidWithString:jidBenutzer]; self.xmppStream.myJID = jid; [[self xmppStream] registerWithPassword:pw error:&err]; NSLog(@"Connection: %@",error); NSLog(@"Register: %@",err); } 

I hope you help me!

+4
source share
4 answers

From your sample code, I don't see any call:

 [xmppStream connect:&error] 

From the error message you are not actually connected.

Make sure that you call the connection method correctly and that you handle the error accordingly.

0
source
 /** * This method attempts to register a new user on the server using the given username and password. * The result of this action will be returned via the delegate methods. * * If the XMPPStream is not connected, or the server doesn't support in-band registration, this method does nothing. **/ 

This is below.

  - (BOOL)registerWithPassword:(NSString *)password error:(NSError **)errPtr 

Instructions for the method. You will find that you must connect a server before using this method.

I can not find below.

  [xmppStream connect:&error] 

I am using this.

  NSError *error; NSString *tjid = [[NSString alloc] initWithFormat:@" anonymous@ %@", serverName]; isRegister = YES; [xmppStream setMyJID:[XMPPJID jidWithString:tjid]]; [xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error] 
0
source

Please make sure your openfire server is enabled from your system settings.

0
source

This is a late answer, but still for any new developer like me: you must register anonymously before registering: for example, you are logged in with your @yourserver name and your password is trying to log in with an unknown @ your server, and for do not enter a password. Thus, it will connect the stream, but will not be authenticated, this is necessary for registration. The stream must be connected, but must not be authenticated.

0
source

Source: https://habr.com/ru/post/1433162/


All Articles