In iOS 6, xmppStreamDidDisconnect:withError: is not called when network connection is lost. #119

Open
iamjiex opened this Issue Oct 29, 2012 · 36 comments

Comments

Projects
None yet
@iamjiex

iamjiex commented Oct 29, 2012

In iOS 5, it works as expect.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Nov 6, 2012

I also confirm this.

jonasman commented Nov 6, 2012

I also confirm this.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Nov 12, 2012

Are you using Secure connection?

Are you using Secure connection?

@tarikhs

This comment has been minimized.

Show comment Hide comment
@tarikhs

tarikhs Nov 21, 2012

yes it is not working in ios6

tarikhs commented Nov 21, 2012

yes it is not working in ios6

@obaidjawad

This comment has been minimized.

Show comment Hide comment
@obaidjawad

obaidjawad Dec 25, 2012

I don't think so that could be the issue with iOS 6 it is something different because I have compiled my application in iOS 6.0 and 6.0.1 it works fine. When it gets disconnected it calls up the xmppStreamDiddisconnect and also it gets reconnected after the scheduled time by the XMPP library.

I don't think so that could be the issue with iOS 6 it is something different because I have compiled my application in iOS 6.0 and 6.0.1 it works fine. When it gets disconnected it calls up the xmppStreamDiddisconnect and also it gets reconnected after the scheduled time by the XMPP library.

@basants

This comment has been minimized.

Show comment Hide comment
@basants

basants Jan 4, 2013

Facing the same issue ? Anyone got any idea abt this one ?

basants commented Jan 4, 2013

Facing the same issue ? Anyone got any idea abt this one ?

@asendra

This comment has been minimized.

Show comment Hide comment
@asendra

asendra Jan 14, 2013

Any good workaround for this? I get disconnected even when changing from wifi to 3G, and it takes around 240seconds for it to call xmppStreamDiddisconnect, (which isn't acceptable in my case) and even then It fails to reconnect.

asendra commented Jan 14, 2013

Any good workaround for this? I get disconnected even when changing from wifi to 3G, and it takes around 240seconds for it to call xmppStreamDiddisconnect, (which isn't acceptable in my case) and even then It fails to reconnect.

@basants

This comment has been minimized.

Show comment Hide comment
@basants

basants Jan 15, 2013

Am also stuck in the same one. Disconnect wont just get called in iOS 6
when wifi goes. Work fine in iOS 5 Anyone ?

On Tue, Jan 15, 2013 at 5:23 AM, Alberto Sendra notifications@github.comwrote:

Any good workaround for this? I get disconnected even when changing from
wifi to 3G, and it takes around 240seconds for it to call
xmppStreamDiddisconnect, (which isn't acceptable in my case) and even then
It fails to reconnect.


Reply to this email directly or view it on GitHubhttps://github.com/robbiehanson/XMPPFramework/issues/119#issuecomment-12246641.

basants commented Jan 15, 2013

Am also stuck in the same one. Disconnect wont just get called in iOS 6
when wifi goes. Work fine in iOS 5 Anyone ?

On Tue, Jan 15, 2013 at 5:23 AM, Alberto Sendra notifications@github.comwrote:

Any good workaround for this? I get disconnected even when changing from
wifi to 3G, and it takes around 240seconds for it to call
xmppStreamDiddisconnect, (which isn't acceptable in my case) and even then
It fails to reconnect.


Reply to this email directly or view it on GitHubhttps://github.com/robbiehanson/XMPPFramework/issues/119#issuecomment-12246641.

@basants

This comment has been minimized.

Show comment Hide comment
@basants

basants Feb 1, 2013

Any updates on this ? Anyone ?

basants commented Feb 1, 2013

Any updates on this ? Anyone ?

@paulmelnikow

This comment has been minimized.

Show comment Hide comment
@paulmelnikow

paulmelnikow Feb 1, 2013

Contributor

I got around this using a combination of XMPPReconnect and XMPPAutoPing.

Contributor

paulmelnikow commented Feb 1, 2013

I got around this using a combination of XMPPReconnect and XMPPAutoPing.

@basants

This comment has been minimized.

Show comment Hide comment
@basants

basants Feb 4, 2013

Can you please explain how you did that ?

On Fri, Feb 1, 2013 at 9:25 PM, Paul Melnikow notifications@github.comwrote:

I got around this using a combination of XMPPReconnect and XMPPAutoPing.


Reply to this email directly or view it on GitHubhttps://github.com/robbiehanson/XMPPFramework/issues/119#issuecomment-12999930.

basants commented Feb 4, 2013

Can you please explain how you did that ?

On Fri, Feb 1, 2013 at 9:25 PM, Paul Melnikow notifications@github.comwrote:

I got around this using a combination of XMPPReconnect and XMPPAutoPing.


Reply to this email directly or view it on GitHubhttps://github.com/robbiehanson/XMPPFramework/issues/119#issuecomment-12999930.

@paulmelnikow

This comment has been minimized.

Show comment Hide comment
@paulmelnikow

paulmelnikow Feb 4, 2013

Contributor

Basically like this:

self.xmppReconnect = [[XMPPReconnect alloc] initWithDispatchQueue:dispatch_get_main_queue()];
[self.xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self.xmppReconnect activate:self.xmppStream];
self.xmppAutoPing = [[XMPPAutoPing alloc] initWithDispatchQueue:dispatch_get_main_queue()];
self.xmppAutoPing.pingInterval = 25.f; // default is 60
self.xmppAutoPing.pingTimeout = 10.f; // default is 10
[self.xmppAutoPing addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self.xmppAutoPing activate:self.xmppStream];

After losing connectivity, the ping requests end up triggering a reconnect. This is for use between servers on a small LAN. You might need longer intervals for your application. It works well.

Contributor

paulmelnikow commented Feb 4, 2013

Basically like this:

self.xmppReconnect = [[XMPPReconnect alloc] initWithDispatchQueue:dispatch_get_main_queue()];
[self.xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self.xmppReconnect activate:self.xmppStream];
self.xmppAutoPing = [[XMPPAutoPing alloc] initWithDispatchQueue:dispatch_get_main_queue()];
self.xmppAutoPing.pingInterval = 25.f; // default is 60
self.xmppAutoPing.pingTimeout = 10.f; // default is 10
[self.xmppAutoPing addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self.xmppAutoPing activate:self.xmppStream];

After losing connectivity, the ping requests end up triggering a reconnect. This is for use between servers on a small LAN. You might need longer intervals for your application. It works well.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Mar 21, 2013

this is the same as: #101

this is the same as: #101

@bluemoon

This comment has been minimized.

Show comment Hide comment
@bluemoon

bluemoon Mar 31, 2013

@noa-- do you then just disconnect using the reconnect manager?

@noa-- do you then just disconnect using the reconnect manager?

@basants

This comment has been minimized.

Show comment Hide comment
@basants

basants Apr 1, 2013

We have used the Reachability class for this.

On Sun, Mar 31, 2013 at 6:33 AM, Bradford Toney notifications@github.comwrote:

@noa-- https://github.com/noa-- do you then just disconnect using the
reconnect manager?


Reply to this email directly or view it on GitHubhttps://github.com/robbiehanson/XMPPFramework/issues/119#issuecomment-15684816
.

basants commented Apr 1, 2013

We have used the Reachability class for this.

On Sun, Mar 31, 2013 at 6:33 AM, Bradford Toney notifications@github.comwrote:

@noa-- https://github.com/noa-- do you then just disconnect using the
reconnect manager?


Reply to this email directly or view it on GitHubhttps://github.com/robbiehanson/XMPPFramework/issues/119#issuecomment-15684816
.

@aguzmanballen

This comment has been minimized.

Show comment Hide comment
@aguzmanballen

aguzmanballen Apr 20, 2013

You could also look at the XMPPAutoPing.h file and see that one of the functions that is called when the program doesn't receive anything back from a ping is the "XMPPAutoPingDidTimeOut" callback function. Thought this could be beneficial for some of you, since it did help me.

You could also look at the XMPPAutoPing.h file and see that one of the functions that is called when the program doesn't receive anything back from a ping is the "XMPPAutoPingDidTimeOut" callback function. Thought this could be beneficial for some of you, since it did help me.

@harryworld

This comment has been minimized.

Show comment Hide comment
@harryworld

harryworld Jun 6, 2013

I confirmed this, it happens sometimes, not always
My workaround is XMPPAutoPing with 2 sec timeout
Also we implemented an API call to openfire presence API to check whether the user is marked online on server side

I confirmed this, it happens sometimes, not always
My workaround is XMPPAutoPing with 2 sec timeout
Also we implemented an API call to openfire presence API to check whether the user is marked online on server side

@CeccoCQ

This comment has been minimized.

Show comment Hide comment
@CeccoCQ

CeccoCQ Jun 6, 2013

The XMPPAutoPing can be used with XMPPAutoReconnect, but a small timeout (for example 2 sec) could cause a big load to openfire server.

Openfire provides some external plugins that allows a user to get the presence via http request.

CeccoCQ commented Jun 6, 2013

The XMPPAutoPing can be used with XMPPAutoReconnect, but a small timeout (for example 2 sec) could cause a big load to openfire server.

Openfire provides some external plugins that allows a user to get the presence via http request.

@harryworld

This comment has been minimized.

Show comment Hide comment
@harryworld

harryworld Jun 7, 2013

@CeccoCQ Our environment happens that the connection is always unstable, even the app is switched on, and friends are sending messages, my device cannot receive. We need some real-time solution.

What is the usual take of timeout? By the way, our XMPPAutoPing interval is 10s.

@CeccoCQ Our environment happens that the connection is always unstable, even the app is switched on, and friends are sending messages, my device cannot receive. We need some real-time solution.

What is the usual take of timeout? By the way, our XMPPAutoPing interval is 10s.

@CeccoCQ

This comment has been minimized.

Show comment Hide comment
@CeccoCQ

CeccoCQ Jun 7, 2013

I've your same problems.

I've solved using 15 seconds of AutoPing by client and 15 second of XMPP Server ping. Obviously, the client timeout started with 15 seconds of delay, so I can check any slot of time by client or server.

About disconnection, are you using a muc? If your client was disconnected from network you can use the remote push notification system provides by Apple. So if you are disconnected, you'll receive the push notification and reconnect to xmpp server then download the enqueued messages.

CeccoCQ commented Jun 7, 2013

I've your same problems.

I've solved using 15 seconds of AutoPing by client and 15 second of XMPP Server ping. Obviously, the client timeout started with 15 seconds of delay, so I can check any slot of time by client or server.

About disconnection, are you using a muc? If your client was disconnected from network you can use the remote push notification system provides by Apple. So if you are disconnected, you'll receive the push notification and reconnect to xmpp server then download the enqueued messages.

@shvekiasaf

This comment has been minimized.

Show comment Hide comment
@shvekiasaf

shvekiasaf Aug 22, 2013

I found the answer here:
robbiehanson/CocoaAsyncSocket#131

I have removed the static term from the CFReadStreamCallback and CFWriteStreamCallback functions.
It seems that callback functions in iOS6 cannot be static..

Good luck.

I found the answer here:
robbiehanson/CocoaAsyncSocket#131

I have removed the static term from the CFReadStreamCallback and CFWriteStreamCallback functions.
It seems that callback functions in iOS6 cannot be static..

Good luck.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Aug 30, 2013

I will give it a try next week :) if this solves the problem then It is great!

I will give it a try next week :) if this solves the problem then It is great!

@asrafarifin78

This comment has been minimized.

Show comment Hide comment
@asrafarifin78

asrafarifin78 Oct 5, 2013

Hi jonasman,

-Did you solve the reconnect problem?

-I need to find a solution where xmppReconnect immediately after get xmppStreamDidDisconnect event.

-So far it takes a bit long to reconnect after get disconnect event.

I'm appreciate if you can help me on this problem,

Thank you

Hi jonasman,

-Did you solve the reconnect problem?

-I need to find a solution where xmppReconnect immediately after get xmppStreamDidDisconnect event.

-So far it takes a bit long to reconnect after get disconnect event.

I'm appreciate if you can help me on this problem,

Thank you

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Oct 5, 2013

Hi.

Didn't try yet. What i did was to rewrite the reconnect module to detect internet changed and disconnect And connect the stream.

jonasman commented Oct 5, 2013

Hi.

Didn't try yet. What i did was to rewrite the reconnect module to detect internet changed and disconnect And connect the stream.

@asrafarifin78

This comment has been minimized.

Show comment Hide comment
@asrafarifin78

asrafarifin78 Oct 5, 2013

I used that one,but it is a bit risky.

If I disconnect,and then connect,if there is still an error,the application will be disconnect forever, until I restart the application.

do you get this message "ioq_select Attempting to replace UDP socket" while the your application is running and the iphone is locked?

if we get the message more than 15 times within 5 minutes,our application will be terminated by kernel

Appreciate if you can share here,may be you have other idea.

Thank you

I used that one,but it is a bit risky.

If I disconnect,and then connect,if there is still an error,the application will be disconnect forever, until I restart the application.

do you get this message "ioq_select Attempting to replace UDP socket" while the your application is running and the iphone is locked?

if we get the message more than 15 times within 5 minutes,our application will be terminated by kernel

Appreciate if you can share here,may be you have other idea.

Thank you

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Oct 5, 2013

I dont run my app that much in background just a few mins.

I never seen that error.

For me that approach has been working fine :)

jonasman commented Oct 5, 2013

I dont run my app that much in background just a few mins.

I never seen that error.

For me that approach has been working fine :)

@asrafarifin78

This comment has been minimized.

Show comment Hide comment
@asrafarifin78

asrafarifin78 Oct 5, 2013

That problem is not because of running background.

it happen wheh your iphone is locked.

Once your application start running,just lock the iphone using power button.

You can see the error when there is incoming message on didReceieveIQ function from debugger.

Just try it,and have a look on that error.

I posted this problem in this forum,and there is no solution except throttle the incoming message from server.

That problem is not because of running background.

it happen wheh your iphone is locked.

Once your application start running,just lock the iphone using power button.

You can see the error when there is incoming message on didReceieveIQ function from debugger.

Just try it,and have a look on that error.

I posted this problem in this forum,and there is no solution except throttle the incoming message from server.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Oct 5, 2013

Im not yet using the lasted code from repo. But in my version i never sen that.

You probably have to dig into the async socket code and try to find out. Who is trhowing that message.
I think it is wierd an udp error cause xmpp connection is tcp.

jonasman commented Oct 5, 2013

Im not yet using the lasted code from repo. But in my version i never sen that.

You probably have to dig into the async socket code and try to find out. Who is trhowing that message.
I think it is wierd an udp error cause xmpp connection is tcp.

@asrafarifin78

This comment has been minimized.

Show comment Hide comment
@asrafarifin78

asrafarifin78 Oct 5, 2013

I believe that message came from kernel.

Yes,XMPP connection is using tcp connection.

But the moderator said,it may be because of XMMPFramework,because it happen only there is message coming from server to the Framework while the iphone is locked.

The only solution for now is throttle the incoming message.

I believe that message came from kernel.

Yes,XMPP connection is using tcp connection.

But the moderator said,it may be because of XMMPFramework,because it happen only there is message coming from server to the Framework while the iphone is locked.

The only solution for now is throttle the incoming message.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Nov 13, 2013

Did anyone added this fix to this repo?

This one: robbiehanson/CocoaAsyncSocket#131

Did anyone added this fix to this repo?

This one: robbiehanson/CocoaAsyncSocket#131

@ObjColumnist

This comment has been minimized.

Show comment Hide comment
@ObjColumnist

ObjColumnist Nov 13, 2013

Collaborator

It didn't work when I tested it so no, I think it is just how sockets work on iOS 6.

Collaborator

ObjColumnist commented Nov 13, 2013

It didn't work when I tested it so no, I think it is just how sockets work on iOS 6.

@jonasman

This comment has been minimized.

Show comment Hide comment
@jonasman

jonasman Feb 10, 2014

any news about iOS 7?

any news about iOS 7?

@ObjColumnist

This comment has been minimized.

Show comment Hide comment
@ObjColumnist

ObjColumnist Feb 10, 2014

Collaborator

It is the same.

Collaborator

ObjColumnist commented Feb 10, 2014

It is the same.

@chauhan1009

This comment has been minimized.

Show comment Hide comment
@chauhan1009

chauhan1009 Sep 4, 2014

I am working on chat app using xmpp framework. I am facing connection issue on 3G network when network goes off or i put the device on airplane mode the application does not connect again it try to reconnect but connection never goes successful. I had tried all the options mention in the post buy unfortunately none of them is working in my case.

the application is working fine on WiFi network automatically reconnect on network failure, when network come again.

Kindly help me out to fix the reconnection issue on 3G network.
Looking for kind help

Regards,
Chauhan

I am working on chat app using xmpp framework. I am facing connection issue on 3G network when network goes off or i put the device on airplane mode the application does not connect again it try to reconnect but connection never goes successful. I had tried all the options mention in the post buy unfortunately none of them is working in my case.

the application is working fine on WiFi network automatically reconnect on network failure, when network come again.

Kindly help me out to fix the reconnection issue on 3G network.
Looking for kind help

Regards,
Chauhan

@ObjColumnist

This comment has been minimized.

Show comment Hide comment
@ObjColumnist

ObjColumnist Sep 4, 2014

Collaborator

Sounds like #426

In short you can manually disconnect the socket yourself when reachability changes, but the XMPPStream is waiting for the OS to tell it that the connection has gone.

Collaborator

ObjColumnist commented Sep 4, 2014

Sounds like #426

In short you can manually disconnect the socket yourself when reachability changes, but the XMPPStream is waiting for the OS to tell it that the connection has gone.

@chauhan1009

This comment has been minimized.

Show comment Hide comment
@chauhan1009

chauhan1009 Sep 17, 2014

I am manually disconnect the socket yourself when reachability changes, but at this time data is clear on UI.

I am manually disconnect the socket yourself when reachability changes, but at this time data is clear on UI.

@ObjColumnist

This comment has been minimized.

Show comment Hide comment
@ObjColumnist

ObjColumnist Sep 17, 2014

Collaborator

This is expected, take a look at the autoClearAllUsersAndResources property onXMPPRoster

/**
 * Whether or not to automatically clear all Users and Resources when the stream disconnects.
 * If you are using XMPPRosterCoreDataStorage you may want to set autoRemovePreviousDatabaseFile to NO.
 *
 * All Users and Resources will be cleared when the roster is next populated regardless of this property.
 *
 * The default value is YES.
**/
@property (assign) BOOL autoClearAllUsersAndResources;
Collaborator

ObjColumnist commented Sep 17, 2014

This is expected, take a look at the autoClearAllUsersAndResources property onXMPPRoster

/**
 * Whether or not to automatically clear all Users and Resources when the stream disconnects.
 * If you are using XMPPRosterCoreDataStorage you may want to set autoRemovePreviousDatabaseFile to NO.
 *
 * All Users and Resources will be cleared when the roster is next populated regardless of this property.
 *
 * The default value is YES.
**/
@property (assign) BOOL autoClearAllUsersAndResources;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment