OpenFire GCDAsyncSocket timeout error with iOS XMPPFramework #322

Closed
sreelash opened this Issue Mar 5, 2014 · 1 comment

Projects

None yet

2 participants

@sreelash

Hi,

First of all, I wanna let you know that I have implemented the file receiving successfully in my chat client app. But I am facing a time out error in a scenario. Now, I am explaining the scenario which got works. When the client receives any file transfer request, it automatically negotiates and start receiving the file data. The XML responses for the handshake is follows

2014-02-27 18:01:13:217 ChatClientApp[3101:450f] RECV: <iq xmlns="jabber:client" id="hmM21-143" to="rajesh.rajan@chat.speridian.com/821b2467" from="sreelash.s@chat.speridian.com/spark" type="set"><si xmlns="http://jabber.org/protocol/si" id="jsi_8344684861296831174" mime-type="image/jpeg" profile="http://jabber.org/protocol/si/profile/file-transfer"><file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="HD-Wallpaper-Nature.jpg" size="802601"><desc>Sending file</desc></file><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form"><field var="stream-method" type="list-multi"><option><value>http://jabber.org/protocol/bytestreams</value></option><option><value>http://jabber.org/protocol/ibb</value></option></field></x></feature></si></iq>

2014-02-27 18:01:13.217 ChatClientApp[3101:70b] IQ Type : set
2014-02-27 18:01:13:219 ChatClientApp[3101:450f] SEND: http://jabber.org/protocol/bytestreams
2014-02-27 18:01:13:430 ChatClientApp[3101:450f] RECV:
2014-02-27 18:01:13.430 ChatClientApp[3101:70b] IQ Type : set
2014-02-27 18:01:13:433 ChatClientApp[3101:450f] SEND:
2014-02-27 18:01:13.433 ChatClientApp[3101:70b] TURN Connection succeeded!
2014-02-27 18:01:13.434 ChatClientApp[3101:70b] You now have a socket that you can use to send/receive data to/from the other person.
2014-02-27 18:01:13.552 ChatClientApp[3101:70b] Partial data length : 40960
2014-02-27 18:01:13.553 ChatClientApp[3101:70b] Partial data length : 385024
2014-02-27 18:01:13.554 ChatClientApp[3101:70b] Partial data length : 163840
2014-02-27 18:01:13.576 ChatClientApp[3101:70b] Partial data length : 8192
2014-02-27 18:01:13.576 ChatClientApp[3101:70b] Partial data length : 57344
2014-02-27 18:01:13.577 ChatClientApp[3101:70b] Partial data length : 57344
2014-02-27 18:01:13.578 ChatClientApp[3101:70b] Partial data length : 49152
2014-02-27 18:01:13.579 ChatClientApp[3101:70b] Partial data length : 32768
2014-02-27 18:01:13.580 ChatClientApp[3101:70b] FINISHED 802601
2014-02-27 18:01:13.580 ChatClientApp[3101:70b] SOCKS5 socket disconnected

Now the problem comes in the following scenario. I want to implement the file receiving upon recipient acceptance. In this case, I did the negotiation process up to as follows

2014-03-03 18:33:44:646 ChatClientApp[5315:180f] RECV: <iq xmlns="jabber:client" id="M635J-78" to="sreelash.s@chat.speridian.com/90d985fb" from="rajesh.rajan@chat.speridian.com/spark" type="set"><si xmlns="http://jabber.org/protocol/si" id="jsi_6594576052416399207" mime-type="image/jpeg" profile="http://jabber.org/protocol/si/profile/file-transfer"><file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="HD-Wallpaper-Nature.jpg" size="802601"><desc>Sending</desc></file><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form"><field var="stream-method" type="list-multi"><option><value>http://jabber.org/protocol/bytestreams</value></option><option><value>http://jabber.org/protocol/ibb</value></option></field></x></feature></si></iq>

2014-03-03 18:33:44.646 ChatClientApp[5315:70b] IQ Type : set
2014-03-03 18:33:44:647 ChatClientApp[5315:740f] SEND: http://jabber.org/protocol/bytestreams
2014-03-03 18:33:44:807 ChatClientApp[5315:740f] RECV:

The final step of Turning the socket connect ON is executing only when the user clicks the accept button and it executes the following code

_turnSocketForFileReceive = [[TURNSocket alloc] initWithStream:xmppStream incomingTURNRequest:inIQ];
[_turnSocketForFileReceive startWithDelegate:self delegateQueue:dispatch_get_main_queue()];

If I accept the button within 10 sec from which I get the request, everything works fine. If I accept the request after that time period, I am getting the following error:

Error Domain=GCDAsyncSocketErrorDomain Code=3 "Attempt to connect to host timed out" UserInfo=0x178d0710 {NSLocalizedDescription=Attempt to connect to host timed out}
Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo=0x178d3e50 {NSLocalizedFailureReason=Error in connect() function, NSLocalizedDescription=Connection refused}

In the TurnSocket class, I have found various timeout MACROS as below:
// Define various timeouts (in seconds)
#define TIMEOUT_DISCO_ITEMS 8.00
#define TIMEOUT_DISCO_INFO 8.00
#define TIMEOUT_DISCO_ADDR 5.00
#define TIMEOUT_CONNECT 8.00
#define TIMEOUT_READ 5.00
#define TIMEOUT_TOTAL 80.00

How this issue can be resolved? Or is XMPPFramework will work only in this manner. After the particular time period, do the TurnSocket connection get disconnect?

Please help me if possible.

Thanks in advance

@sreelash

Hi, The issue got resolved. Actually there are 2 handshake processes for file receiving in XMPP. When a file receive request come to didReceiveIQ method, the file acceptance request to the chatviewcontroller should be send after receiving the 1st handshake process, not after negotiation. I was implemented the file acceptance after the negotiation process and in this case, opening the TurnSocket connection holds till the user accepts the request. By this time, something was happening in the AsyncSocket or TurnSocket class, which I couldn't find out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment