robbiehanson/CocoaAsyncSocket — Issue #29: Socket closed by remote peer after 2 minutes
Author: Zyphrax
Created: 2012-02-25 14:14:13+00:00
State: open

In my iOS application I'm communicating with a STAR printer via a socket on port 9101 (discovered via NSNetServices). I have been able to reduce my code a lot by using the GCDAsyncSocket library (thanks!)

The STAR printer is continuously sending me its status (about 2 times a second). I'm using readDataWithTimeout and didReadData to process the status communicated by the printer. Everything is working fine.

However after exactly two minutes the connection is disconnected with error: Socket closed by remote peer.

I didn't have this problem with my own implementation based on NSNetService getInputOutputstream. It seems that GCDAsyncSocket assumes the connection is gone even though it isn't? I've tried AsyncSocket as well instead of GCDAsyncSocket: same problem.

How can I determine what is closing the socket?

I'm testing on the iPad simulator targeted at iOS 5.