Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
Derek #1
Member since Jun 2006 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Open and closing connection: out of memory.
I seem to be running into a problem when I need to close and reconnect my xmpp connection more than once. I'm trying to get my app to automatically reconnect after the connection closes (due to network error, or whatever). It works the first time and everything is fine. If I disconnect again, I reconnect again fine but the next time I try to create any sort of window I'm running into memory errors (memory could not be "read", out of memory errors, could not create handle).

I've tried putting the reconnect code on a timer and then on a button to manually reconnect. I've removed any extraneous functions from the onLogin and onClose events thinking maybe it was something I was doing. I've tried setting the connection to null and recreating the connection rather than just calling Open() (because I saw people were having trouble with this a while ago). I've also tried pulling down the latest code through svn and still get the same behavior.

If you could shed any light on this or give me any ideas it would be greatly appreciated. Thanks.
Avatar
Derek #2
Member since Jun 2006 · 6 posts
Group memberships: Members
Show profile · Link to this post
Oops posted this in the wrong forum. Could I get it moved to support?
Avatar
Derek #3
Member since Jun 2006 · 6 posts
Group memberships: Members
Show profile · Link to this post
To be clear, this only happens when disabling/enabling my internet connection. If I actually close the connection and reopen it, everything is fine. It seems like something isn't being cleaned up when I lose my net connection. Is there some event or something I can use to check for this? onError doesn't fire when I lose my connection.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello Derek,

i don't have this problem. If i disconnect my network i get a OnClose in XmppClientConnection.
Can you write a small test case which causes this error?
Are you on Desktop, PocketPC or SmartPhone?
You often get out of memory errors in .NET when you run in a endless loop.

Alex
Avatar
simonj #5
Member since Jul 2006 · 1 post
Group memberships: Members
Show profile · Link to this post
Hi Derek,

How are you trapping the connection closing. OnClose doesn't seem to fire if the GPRS connection simply drops (e.g. going through a tunnel). Is there any way around this other than checking on a timer?

Simon
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

we has similar problems on GPRS or wireless Pocket PCs. They don't close the connection if you loose signal or if you are out of range. If we got the signal again we got all messages delivered. So the socket behaves like it never disconneced. I think this is by design of the wireless stack, because it also supports hopping from one access point to the other, or switching from GPRS to WLAN or Bluetooth without loosing the connection.

Alex
Avatar
Derek #7
Member since Jun 2006 · 6 posts
Group memberships: Members
Show profile · Link to this post
When I disable and enable my network adapter, I still get an onClose event...it seems this is the only event that fires?

After doing more testing I can't be entirely sure it's the agsxmpp library that is causing this weirdness. But it's the fact that nothing else in our program does anything with the network while idling that leads me in that direction. It seems to do random things when disabling and enabling my net connection. For instance, today I got this when I disabled my network:

Additional information: IO exception during Write.


Unhandled Exception: System.IO.IOException: IO exception during Write. ---> System.IO.IOException: Unable to write data to the transport connection. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
   at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   at Mono.Security.Protocol.Tls.SslStreamBase.InternalBeginWrite(InternalAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at Mono.Security.Protocol.Tls.SslStreamBase.InternalBeginWrite(InternalAsyncResult asyncResult)
   at Mono.Security.Protocol.Tls.SslStreamBase.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
   at agsXMPP.net.ClientSocket.Send(Byte[] bData)
   at agsXMPP.net.ClientSocket.Send(String data)
   at agsXMPP.XmppConnection.Send(String xml)
   at agsXMPP.XmppClientConnection.KeepAliveTick(Object state)

Plus I can't reproduce it on every machine...it's been quite hard to track down.
Avatar
Alex #8
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello Derek,

this IO exception meaans that there was an attempt to send data on a closed connection.
Can you try to set a breakpoint on the Send Member of ClientSocket of the Send Members in XmppClientConnection. Then you perhaps can see who is trying to send Data on a closed socket.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS