xmpp - xmppsream connection issue in iOS - Unable to authenticate with password -
i developing chat system in both ios. chat server using ejabbered server. using robbiehanson xmppframework
ios chat client.
the issue facing not able establish proper xmppstream between chat client , server. xmppstream state in state_xmpp_registering
. holds value of 8. due this,when try authenticate created registered user, encountering exception
"error authenticating: error domain=xmppstreamerrordomain code=1 "please wait until stream connected." userinfo=0x166c1e30 {nslocalizeddescription=please wait until stream connected.}
but surprisingly, able register user using password. when try authenticate user, encountering exception due registered user not able appear online.
i using connectwithtimeout
connect xmppstream server
nsstring *mypassword = @"password"; if (myjid == nil || mypassword == nil) { return no; } [xmppstream setmyjid:[xmppjid jidwithstring:myjid]]; password = mypassword; nserror *error = nil; if (![xmppstream connectwithtimeout:xmppstreamtimeoutnone error:&error]) { uialertview *alertview = [[uialertview alloc] initwithtitle:@"error connecting" message:@"see console error details." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertview show]; ddlogerror(@"error connecting: %@", error); return no; }
using above code, able establish connection server.
once connectton established, xmppstreamdidconnect invoked.
when checked status of xmppstream, seeing stream connected. below code.
- (void)xmppstreamdidconnect:(xmppstream *)sender
{
if ([xmppstream isdisconnected]){ nslog(@"is disconnected"); [self connect]; } if ([xmppstream isconnecting]){ nslog(@"is connecting"); } if ([xmppstream isconnecting]){ nslog(@"is connecting"); } if ([xmppstream isconnected]){ nslog(@"is connected"); } nserror *error = nil; if (![[self xmppstream] registerwithpassword:@"password" error:&error]) { nslog(@"registration error: %@", error); } if (![[self xmppstream] authenticatewithpassword:password error:&error]) { ddlogerror(@"error authenticating: %@", error); }else{ [self goonline]; xmpppresence *presence = [xmpppresence presencewithtype:@"available"]; [sender sendelement:presence]; }
as per above code, user registered , here comes issue. when try authenticate user, using authenticatewithpassword:password
xmpplogtrace(); // given password parameter mutable nsstring *password = [inpassword copy]; __block bool result = yes; __block nserror *err = nil; dispatch_block_t block = ^{ @autoreleasepool { if (state != state_xmpp_connected) { nsstring *errmsg = @"please wait until stream connected."; nsdictionary *info = [nsdictionary dictionarywithobject:errmsg forkey:nslocalizeddescriptionkey]; err = [nserror errorwithdomain:xmppstreamerrordomain code:xmppstreaminvalidstate userinfo:info]; result = no; return_from_block; } if (myjid_setbyclient == nil) { nsstring *errmsg = @"you must set myjid before calling authenticate:error:."; nsdictionary *info = [nsdictionary dictionarywithobject:errmsg forkey:nslocalizeddescriptionkey]; err = [nserror errorwithdomain:xmppstreamerrordomain code:xmppstreaminvalidproperty userinfo:info]; result = no; return_from_block; }
the code below gets executed. when check status of xmppstream when enter delegate, seeing in status 8 (which state_xmpp_registering) though user registered. status makes return no , hence registered user not appearing online.
could please me in resolving issue. tried lot of ways. not able progress.
why not able move next status , status 12 before authenticatewithpassword
invoked. missing intermediate steps after establishing connection , successful registration. in nutshell, why stream state stops @ 8. , not going forward state_xmpp_auth,state_xmpp_binding
,state_xmpp_start_session
, state_xmpp_connected
, before getting authenticatewithpassword
logs more info.
2014-05-30 07:40:20:995 konnectlinks[3249:8403] send: <?xml version='1.0'?> 2014-05-30 07:40:20:996 konnectlinks[3249:8403] send: <stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='localhost'> 2014-05-30 07:40:21.246 konnectlinks[3249:60b] dhaval here 2014-05-30 07:40:21:608 konnectlinks[3249:4717] recv: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="114321716" from="localhost" version="1.0" stream1:lang="en"/> 2014-05-30 07:40:21:609 konnectlinks[3249:8403] recv: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>scram-sha-1</mechanism><mechanism>digest-md5</mechanism><mechanism>plain</mechanism></mechanisms><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="9dvbxp9c/vtyb5mlfy7wktk5pfs="/><register xmlns="http://jabber.org/features/iq-register"/></stream:features> 2014-05-30 07:40:21.610 konnectlinks[3249:8403] -[xmppreconnect xmppstreamdidconnect:] 2014-05-30 07:41:01.558 konnectlinks[3249:60b] connected 2014-05-30 07:41:01.561 konnectlinks[3249:8403] -[xmppreconnect setmultiplereachabilitychanges:] 2014-05-30 07:41:14.073 konnectlinks[3249:8403] -[xmppreconnect setmanuallystarted:] 2014-05-30 07:41:14.076 konnectlinks[3249:8403] -[xmppreconnect teardownreconnecttimer] 2014-05-30 07:41:14:076 konnectlinks[3249:60b] send: <iq type="set"><query xmlns="jabber:iq:register"><username>timop</username><password>password</password></query></iq> 2014-05-30 07:41:14.077 konnectlinks[3249:8403] -[xmppreconnect teardownnetworkmonitoring] 2014-05-30 07:42:07:428 konnectlinks[3249:860b] recv: <iq xmlns="jabber:client" from="localhost" type="result"><query xmlns="jabber:iq:register"><username>timop</username><password>password</password></query></iq> 2014-05-30 07:42:10:312 konnectlinks[3249:60b] error authenticating: error domain=xmppstreamerrordomain code=1 "please wait until stream connected." userinfo=0x166c1e30 {nslocalizeddescription=please wait until stream connected.}
i sure have encountered issue.
please me in resolving issue. advance time ,
i reviewed code seems right , make sure username , password send must correct. if nothing goes right contact server/web team regarding or try connect creating new user
Comments
Post a Comment