Not logged in. · Lost password · Register
Forum: MatriX RSS
Page:  1  2  next
Avatar
Lightbarrier #1
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Subject: OnError Event Bosh Exception
Hi Alex,

We are using MatriX Version 1.6.0.3 and .NET 4.0.
 
Sometimes I've noticed that while using bosh to connect to our server the OnError event will return an Bosh exception. Following which the MatriX library automatically closes it's connection with our chat server. Do you have any idea why this would occur?

I've watched the OnSend and OnReceived events however, it doesn't seem to send or receive anything when this exception occurs. Thus I'm lead to believe that whatever is happening resides within MatriX which I can't see internally.

Thanks for your assistance.
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
We need your full Stacktrace.
You also don't use a current MatriX version.  Can you update to 2.x?

Alex
Avatar
Lightbarrier #3
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Hey Alex,

I apologize for the late reply.

We're in the middle of updating our client to Matrix .NET 4.0 Version: 2.0.0.12.

Once we're finished with the update and testing I'll let you know if the problem still occurs, and I'll give you the trace log if it does.

Thanks for your assistance.
Avatar
Lightbarrier #4
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
I've been unable to duplicate the error using Matrix 2.x.

However, that doesn't completely remove some of my concerns regarding our Bosh issue. Currently we have an application that's loosing it's Bosh connection to our Chat Sever(Openfire) using Matrix 1.6.0.3, and unfortunately it isn't listening to to the OnError event except for SocketErrors which don't appear to be the problem, thus we don't know why the connection was lost on the client side. From the server side I could see a message that said's the connection idled out in the trace log. I've done some stuff to try and reduce the chance of the issue such as raising the server's http idle out time however, the connection still seems to be lost except without logging that it idled out from the server side. This issue also seems to be sporadic, I've left the chat client connected to our Chat Server for days and it never goes offline, and yet I keep getting cases where the connection is lost in 30 or so minutes. I'm also currently limited to making changes on these environments where the problems are happening, so I can't exactly go fixing their issue regarding it not listening to the onError event immediately.

Looking at the following old link below it seems you might have noticed this issue on Openfire, and have already resolved it.
https://community.igniterealtime.org/thread/47181

Also looking at another link below which appears to be a similar problem, they fixed it by acking to Openfire more frequently, which I know I could do with the "KeepAliveInterval" property within Matrix.
https://social.msdn.microsoft.com/Forums/en-US/3…?forum=…

Do you have any ideas for why this problem might have occurred, or how to fix it?

Thanks for your assistance.
Avatar
Alex #5
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
try to send a XMPP ping to your server on a regular bases, eg. every 2 minutes:
http://xmpp.org/extensions/xep-0199.html

This should tell your server that you are still alive/active.

Alex
Avatar
Lightbarrier #6
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Based on the following below which is the xml of the chat connection starting with the first presence, it seems that Matrix is already sending a ping ever two minutes (Exp: 12/18/2015 9:57:06 AM - SEND: ).

  1. 12/18/2015 9:55:03 AM - SEND: <presence xmlns="jabber:client">
  2.  <status></status>
  3.  <priority>0</priority>
  4. </presence>
  5. 12/18/2015 9:55:04 AM - RECV: <presence xmlns="jabber:client" from="supervisor-agent@nnc4oc7ltwhavow/MatriX" to="supervisor-agent@nnc4oc7ltwhavow/MatriX">
  6.  <status />
  7.  <priority>0</priority>
  8. </presence>
  9. 12/18/2015 9:55:04 AM - SEND: <presence to="boslw@conference.nnc4oc7ltwhavow/supervisor" xmlns="jabber:client">
  10.  <x xmlns="http://jabber.org/protocol/muc" />
  11. </presence>
  12. 12/18/2015 9:55:04 AM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nnc4oc7ltwhavow/MatriX" from="boslw@conference.nnc4oc7ltwhavow/supervisor">
  13.  <x xmlns="http://jabber.org/protocol/muc#user">
  14.     <item jid="supervisor-agent@nnc4oc7ltwhavow/MatriX" affiliation="owner" role="moderator" />
  15.     <status code="110" />
  16.  </x>
  17. </presence>
  18. 12/18/2015 9:55:04 AM - SEND: <presence xmlns="jabber:client">
  19.  <show>away</show>
  20.  <status></status>
  21.  <priority>0</priority>
  22. </presence>
  23. 12/18/2015 9:55:04 AM - SEND: <presence to="boslw@conference.nnc4oc7ltwhavow" xmlns="jabber:client">
  24.  <show>away</show>
  25. </presence>
  26. 12/18/2015 9:55:05 AM - RECV: <presence xmlns="jabber:client" from="supervisor-agent@nnc4oc7ltwhavow/MatriX" to="supervisor-agent@nnc4oc7ltwhavow/MatriX">
  27.  <show>away</show>
  28.  <status />
  29.  <priority>0</priority>
  30. </presence>
  31. 12/18/2015 9:55:05 AM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nnc4oc7ltwhavow/MatriX" from="boslw@conference.nnc4oc7ltwhavow/supervisor">
  32.  <show>away</show>
  33.  <x xmlns="http://jabber.org/protocol/muc#user">
  34.     <item jid="supervisor-agent@nnc4oc7ltwhavow/MatriX" affiliation="owner" role="moderator" />
  35.  </x>
  36. </presence>
  37. 12/18/2015 9:57:06 AM - SEND: 
  38. 12/18/2015 9:59:06 AM - SEND: 
  39. 12/18/2015 10:01:06 AM - SEND: 
  40. 12/18/2015 10:03:06 AM - SEND: 
  41. 12/18/2015 10:05:07 AM - SEND: 
  42. 12/18/2015 10:07:07 AM - SEND: 
  43. 12/18/2015 10:09:01 AM - SEND: <presence to="boslw@conference.nnc4oc7ltwhavow/supervisor" type="unavailable" xmlns="jabber:client" />
  44. 12/18/2015 10:09:01 AM - SEND: </stream:stream>
  45. 12/18/2015 10:09:02 AM - RECV: </stream:stream>

Any thoughts?

Thanks for your assistance.
Avatar
Alex #7
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
thats not really a ping. Try to send a real Xmpp Ping package instead of the keep alives.
We had some users with the same problems before. Openfire seems to kill BOSH connections under some conditions without XMPP traffic when it shouldn't.

We improved the keep alives for BOSH, but you are using a old build which does not seem to have them.

Alex
Avatar
Lightbarrier #8
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Well we are looking at using MatriX Ver: 2.0.0.12 for .NET 4.0. Would that DLL incorporate the update you're talking about? I ask because I didn't see a note of it in the Change log.

The reason why I showed you that log using the older MatriX DLL (Ver: 1.6.0.3 and .NET 4.0) was because it was the version which we know for sure we were having trouble with.

Also, I didn't see any pings or keep alive go out from the OnSendXml event when using the new DLL. However, from wireshark I can see some communication although I can't decrypt what Matrix is sending. I realize not showing the ping within the event could be intentional though, but then is there anywhere I can see it from the client side?

Thanks for your assistance.
Avatar
Lightbarrier #9
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
On a side note, I've managed to duplicate the Bosh Exception on an environment with Matrix .NET 4.0 Version: 2.0.0.12. You can see the xml and the stacktrace for it below.

  1. 12/18/2015 5:56:47 PM - SEND: 
  2. 12/18/2015 5:58:35 PM - SEND: 
  3. 12/18/2015 6:00:23 PM - SEND: 
  4. 12/18/2015 6:00:27 PM - RECV: <presence xmlns="jabber:client" from="lamor382-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  5.  <status />
  6.  <priority>0</priority>
  7. </presence>
  8. 12/18/2015 6:00:27 PM - RECV: <presence xmlns="jabber:client" from="lamor382-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  9.  <show>away</show>
  10.  <status />
  11.  <priority>0</priority>
  12. </presence>
  13. 12/18/2015 6:00:28 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/lamor382">
  14.  <x xmlns="http://jabber.org/protocol/muc#user">
  15.     <item jid="lamor382-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  16.  </x>
  17. </presence>
  18. 12/18/2015 6:00:32 PM - RECV: <presence xmlns="jabber:client" from="lamor382-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  19.  <show>chat</show>
  20.  <status />
  21.  <priority>0</priority>
  22. </presence>
  23. 12/18/2015 6:00:32 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/lamor382">
  24.  <show>chat</show>
  25.  <x xmlns="http://jabber.org/protocol/muc#user">
  26.     <item jid="lamor382-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  27.  </x>
  28. </presence>
  29. 12/18/2015 6:00:33 PM - RECV: <presence xmlns="jabber:client" from="lamor382-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  30.  <show>away</show>
  31.  <status />
  32.  <priority>0</priority>
  33. </presence>
  34. 12/18/2015 6:00:33 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/lamor382">
  35.  <show>away</show>
  36.  <x xmlns="http://jabber.org/protocol/muc#user">
  37.     <item jid="lamor382-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  38.  </x>
  39. </presence>
  40. 12/18/2015 6:00:34 PM - RECV: <presence xmlns="jabber:client" from="lamor382-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  41.  <show>chat</show>
  42.  <status />
  43.  <priority>0</priority>
  44. </presence>
  45. 12/18/2015 6:00:35 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/lamor382">
  46.  <show>chat</show>
  47.  <x xmlns="http://jabber.org/protocol/muc#user">
  48.     <item jid="lamor382-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  49.  </x>
  50. </presence>
  51. 12/18/2015 6:02:24 PM - SEND: 
  52. Event OnError(object sender, ExceptionEventArgs error) error.Exception.Message = BoshException
  53. StackTrace At OnError:
  54.    at Guestware.Common.Chat.MatrixRespond.XmppClientOnError(Object sender, ExceptionEventArgs error)
  55.    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  56.    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
  57.    at System.Delegate.DynamicInvokeImpl(Object[] args)
  58.    at Matrix.XmppStream.DoRaiseEvent(Delegate del, Object[] args)
  59.    at Matrix.XmppStream.socket_OnError(Object sender, ExceptionEventArgs e)
  60.    at Matrix.Net.BoshSocket.HttpRequest_OnError(Object sender, ExceptionEventArgs e)
  61.    at Matrix.Net.WebRequestHelper.OnGetResponse(IAsyncResult ar)
  62.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  63.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  64.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  65.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  66.    at System.Net.HttpWebRequest.ProcessResponse()
  67.    at System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData)
  68.    at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
  69.    at System.Net.Connection.ReadComplete(Int32 bytesRead, WebExceptionStatus errorStatus)
  70.    at System.Net.Connection.ReadCallback(IAsyncResult asyncResult)
  71.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  72.    at System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
  73.    at System.Net.Security._SslStream.ReadFrameCallback(AsyncProtocolRequest asyncRequest)
  74.    at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
  75.    at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
  76.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  77.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  78.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  79.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  80.    at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  81.    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  82.  
  83. 12/18/2015 6:10:02 PM - SEND: </stream:stream>
  84. Event OnError(object sender, ExceptionEventArgs error) error.Exception.Message = BoshException
  85. StackTrace At OnError:
  86.    at Guestware.Common.Chat.MatrixRespond.XmppClientOnError(Object sender, ExceptionEventArgs error)
  87.    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  88.    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
  89.    at System.Delegate.DynamicInvokeImpl(Object[] args)
  90.    at Matrix.XmppStream.DoRaiseEvent(Delegate del, Object[] args)
  91.    at Matrix.XmppStream.socket_OnError(Object sender, ExceptionEventArgs e)
  92.    at Matrix.Net.BoshSocket.HttpRequest_OnError(Object sender, ExceptionEventArgs e)
  93.    at Matrix.Net.WebRequestHelper.OnGetResponse(IAsyncResult ar)
  94.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  95.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  96.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  97.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  98.    at System.Net.HttpWebRequest.ProcessResponse()
  99.    at System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData)
  100.    at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
  101.    at System.Net.Connection.ReadComplete(Int32 bytesRead, WebExceptionStatus errorStatus)
  102.    at System.Net.Connection.ReadCallback(IAsyncResult asyncResult)
  103.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  104.    at System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
  105.    at System.Net.Security._SslStream.ReadFrameCallback(AsyncProtocolRequest asyncRequest)
  106.    at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
  107.    at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
  108.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  109.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  110.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  111.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  112.    at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  113.    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

From the xml and the error above it seems that the Bosh exception occurs, then MatriX attempts to the close the connection only for another Bosh Exception to occur.

Let me know if there's anything else I can give you.
 
Thanks for your assistance.
Avatar
Alex #10
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #8
Quote by Lightbarrier:
Also, I didn't see any pings or keep alive go out from the OnSendXml event when using the new DLL. However, from wireshark I can see some communication although I can't decrypt what Matrix is sending. I realize not showing the ping within the event could be intentional though, but then is there anywhere I can see it from the client side?

MatriX does not send the XmppPings. What I suggested it putting a timer in your code and send them yourself.

Alex
Avatar
Alex #11
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #9
Quote by Lightbarrier:
From the xml and the error above it seems that the Bosh exception occurs, then MatriX attempts to the close the connection only for another Bosh Exception to occur.

Let me know if there's anything else I can give you.

There is an exception in the BoshSocket. Your stacktrace does not show what type of exception it exactly is. Can you try to get more info? It shows only that is goes down all the stack into the .NET Frameworks HttpWebRequest and the underlying socket code.

MatriX internal decides whether it can recover the Bosh session after an exception or not. In your case it sais no, and then tries to close the connection. As this fails immediately as well it looks like MatriX is not able for some reason to Execute HTTP requests against your Openfire server. You can try to fetch the InnerException when available, maybe there is more info.

BOSH is based on HttpWebRequests, we sue the default implementation of the .NET Framework for them.

According to your log the exception comes after ~2 minutes without any XMPP traffic. So the reason could be Openfire killing all Open HTTP connections for this session because it assumes you are inactive. This is why I suggested before to send Xmpp Pings every minute for example to see if its related to this.

  1. xmppClient.Send(new PingIq{To = xmppClient.XmppDomain, Type = IqType.get});

Why are you using BOSH when you want to stay connected 24/7 and should have a reliable internet connection? Plain Sockets work much better with less overhead.

Alex
Avatar
Lightbarrier #12
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex:
There is an exception in the BoshSocket. Your stacktrace does not show what type of exception it exactly is. Can you try to get more info? It shows only that is goes down all the stack into the .NET Frameworks HttpWebRequest and the underlying socket code.

  1. 12/21/2015 4:49:51 PM - SEND: 
  2. 12/21/2015 4:50:02 PM - RECV: <presence xmlns="jabber:client" from="shmen057-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  3.  <show>chat</show>
  4.  <status />
  5.  <priority>0</priority>
  6. </presence>
  7. 12/21/2015 4:50:02 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/shmen057">
  8.  <show>chat</show>
  9.  <x xmlns="http://jabber.org/protocol/muc#user">
  10.     <item jid="shmen057-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  11.  </x>
  12. </presence>
  13. 12/21/2015 4:50:19 PM - RECV: <presence xmlns="jabber:client" from="zwdon857-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  14.  <status />
  15.  <priority>0</priority>
  16. </presence>
  17. 12/21/2015 4:50:20 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/zwdon857">
  18.  <x xmlns="http://jabber.org/protocol/muc#user">
  19.     <item jid="zwdon857-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  20.  </x>
  21. </presence>
  22. 12/21/2015 4:50:21 PM - RECV: <presence xmlns="jabber:client" from="zwdon857-agent@nycwsgw4vm/MatriX" to="supervisor-agent@nycwsgw4vm">
  23.  <show>chat</show>
  24.  <status />
  25.  <priority>0</priority>
  26. </presence>
  27. 12/21/2015 4:50:21 PM - RECV: <presence xmlns="jabber:client" to="supervisor-agent@nycwsgw4vm/MatriX" from="nycws@conference.nycwsgw4vm/zwdon857">
  28.  <show>chat</show>
  29.  <x xmlns="http://jabber.org/protocol/muc#user">
  30.     <item jid="zwdon857-agent@nycwsgw4vm/MatriX" affiliation="owner" role="moderator" />
  31.  </x>
  32. </presence>
  33. 12/21/2015 4:56:29 PM - Matrix.OnError(object sender, ExceptionEventArgs error)
  34. 12/21/2015 4:56:29 PM - error.Exception.GetType(): Matrix.Net.BoshException
  35. 12/21/2015 4:56:29 PM - error.Exception.Message: BoshException
  36. 12/21/2015 4:56:29 PM - error.Exception.GetBaseException().GetType(): System.Net.WebException
  37. 12/21/2015 4:56:29 PM - error.Exception.GetBaseException().Message: The underlying connection was closed: The connection was closed unexpectedly.
  38. 12/21/2015 4:56:30 PM - Stack Trace of Matrix.OnError:    at Guestware.Common.Chat.MatrixRespond.XmppClientOnError(Object sender, ExceptionEventArgs error)
  39.    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  40.    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
  41.    at System.Delegate.DynamicInvokeImpl(Object[] args)
  42.    at Matrix.XmppStream.DoRaiseEvent(Delegate del, Object[] args)
  43.    at Matrix.XmppStream.socket_OnError(Object sender, ExceptionEventArgs e)
  44.    at Matrix.Net.BoshSocket.HttpRequest_OnError(Object sender, ExceptionEventArgs e)
  45.    at Matrix.Net.WebRequestHelper.OnGetResponse(IAsyncResult ar)
  46.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  47.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  48.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  49.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  50.    at System.Net.HttpWebRequest.SetResponse(Exception E)
  51.    at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
  52.    at System.Net.Connection.ReadComplete(Int32 bytesRead, WebExceptionStatus errorStatus)
  53.    at System.Net.Connection.ReadCallback(IAsyncResult asyncResult)
  54.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  55.    at System.Net.Security._SslStream.ProcessReadErrorCode(SecurityStatus errorCode, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest, Byte[] extraBuffer)
  56.    at System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
  57.    at System.Net.Security._SslStream.ReadFrameCallback(AsyncProtocolRequest asyncRequest)
  58.    at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
  59.    at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
  60.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  61.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  62.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  63.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  64.    at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  65.    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  66.  
  67. 12/21/2015 4:56:30 PM - SEND: </stream:stream>

From the looks of the above with the text "The connection was closed unexpectedly" one would assume Openfire closed it however, from Openfire's log file I can see the following.

  1. 2015.12.21 16:57:29 org.jivesoftware.openfire.http.HttpSessionManager - Closing idle session: supervisor-agent@nycwsgw4vm/MatriX

Both Openfire and the app are on the same environment and yet Matrix showed the error before Openfire closed the idle connection. Thus I believe there might be another reason here besides Openfire closing the connection.

Quote by Alex:
According to your log the exception comes after ~2 minutes without any XMPP traffic. So the reason could be Openfire killing all Open HTTP connections for this session because it assumes you are inactive. This is why I suggested before to send Xmpp Pings every minute for example to see if its related to this.

I'm currently in the process of implementing this, and I'll let you know the result of testing it.   

Quote by Alex:
Why are you using BOSH when you want to stay connected 24/7 and should have a reliable internet connection? Plain Sockets work much better with less overhead.

We have users that have to use http due to the server that they're connecting to. Although there are cases where socket connections are ok, for some of our users there are cases where it has to be http or nothing.

Thanks for your assistance.
This post was edited on 2015-12-22, 00:32 by Lightbarrier.
Avatar
Alex #13
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by Lightbarrier:
From the looks of the above with the text "The connection was closed unexpectedly" one would assume Openfire closed it however, from Openfire's log file I can see the following.

MatriX does not close it on its own. Either the server closed it, or there were network problems which closed it.

Quote by Lightbarrier:
We have users that have to use http due to the server that they're connecting to. Although there are cases where socket connections are ok, for some of our users there are cases where it has to be http or nothing.

makes sense for constrained clients.

Does you Software create any other HTTP requests? If yes then you could run into the concurrent HTTP requests limit of the ServicePointManager and need to raise it.

Alex
Avatar
Lightbarrier #14
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
I've setup my client to automaticlly ping the chat server (openfire) using a timer (System.Timers.Timer) with an interval of two minutes. From below you can see the results of adding it.

  1. 12/22/2015 5:52:40 PM - Event Raised to Ping Server
  2. 12/22/2015 5:52:40 PM - this.Send(new PingIq { To = this.XmppDomain, Type = IqType.Get });
  3. 12/22/2015 5:52:40 PM - SEND: <iq id="MX_30" to="nycwsgw4vm" type="get" xmlns="jabber:client">
  4.  <ping xmlns="urn:xmpp:ping" />
  5. </iq>
  6. 12/22/2015 5:52:41 PM - RECV: <iq xmlns="jabber:client" type="result" id="MX_30" from="nycwsgw4vm" to="supervisor-agent@nycwsgw4vm/MatriX" />
  7. 12/22/2015 5:54:28 PM - Event Raised to Ping Server
  8. 12/22/2015 5:54:28 PM - this.Send(new PingIq { To = this.XmppDomain, Type = IqType.Get });
  9. 12/22/2015 5:54:28 PM - SEND: <iq id="MX_31" to="nycwsgw4vm" type="get" xmlns="jabber:client">
  10.  <ping xmlns="urn:xmpp:ping" />
  11. </iq>
  12. 12/22/2015 5:54:29 PM - RECV: <iq xmlns="jabber:client" type="result" id="MX_31" from="nycwsgw4vm" to="supervisor-agent@nycwsgw4vm/MatriX" />
  13. 12/22/2015 6:01:35 PM - Matrix.OnError(object sender, ExceptionEventArgs error)
  14. 12/22/2015 6:01:35 PM - error.Exception.GetType(): Matrix.Net.BoshException
  15. 12/22/2015 6:01:35 PM - error.Exception.Message: BoshException
  16. 12/22/2015 6:01:35 PM - error.Exception.GetBaseException().GetType(): System.Net.WebException
  17. 12/22/2015 6:01:35 PM - error.Exception.GetBaseException().Message: The underlying connection was closed: The connection was closed unexpectedly.
  18. 12/22/2015 6:01:35 PM - Stack Trace of Matrix.OnError:    at Guestware.Common.Chat.MatrixRespond.XmppClientOnError(Object sender, ExceptionEventArgs error)
  19.    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  20.    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
  21.    at System.Delegate.DynamicInvokeImpl(Object[] args)
  22.    at Matrix.XmppStream.DoRaiseEvent(Delegate del, Object[] args)
  23.    at Matrix.XmppStream.socket_OnError(Object sender, ExceptionEventArgs e)
  24.    at Matrix.Net.BoshSocket.HttpRequest_OnError(Object sender, ExceptionEventArgs e)
  25.    at Matrix.Net.WebRequestHelper.OnGetResponse(IAsyncResult ar)
  26.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  27.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  28.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  29.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  30.    at System.Net.HttpWebRequest.SetResponse(Exception E)
  31.    at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
  32.    at System.Net.Connection.ReadComplete(Int32 bytesRead, WebExceptionStatus errorStatus)
  33.    at System.Net.Connection.ReadCallback(IAsyncResult asyncResult)
  34.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  35.    at System.Net.Security._SslStream.ProcessReadErrorCode(SecurityStatus errorCode, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest, Byte[] extraBuffer)
  36.    at System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
  37.    at System.Net.Security._SslStream.ReadFrameCallback(AsyncProtocolRequest asyncRequest)
  38.    at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
  39.    at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
  40.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  41.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  42.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  43.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
  44.    at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  45.    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  46.  
  47. 12/22/2015 6:01:35 PM - SEND: </stream:stream>

As you can see the error still occurs. An interesting thing to note is that there was a pause of six minutes between the last ping and the exception arising which we've noted before. I've searched my code and can't see anything to bring it up thus I believe that the timer just failed to find an suitable thread that it could use to ping Openfire however, I'm still testing for other possibilities.

Quote by Alex:
MatriX does not close it on its own. Either the server closed it, or there were network problems which closed it.

I'll be retrieving the stack trace for when MatriX's Closed event is called and when my software would normally call close to see if I can pinpoint where the closure of the chat connection is coming from.

Quote by Alex:
Does you Software create any other HTTP requests? If yes then you could run into the concurrent HTTP requests limit of the ServicePointManager and need to raise it.

The current client I'm testing does not. Although there are obviously other pieces of software that do, I don't think they would impact the client. However, I can try raising it just to see what happens.
Avatar
Alex #15
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by Lightbarrier:
I've setup my client to automaticlly ping the chat server (openfire) using a timer (System.Timers.Timer) with an interval of two minutes. From below you can see the results of adding it.

try a lower interval, because what your logs showed is that the disconnect appeared at exactly 2 minutes or a bit below. I would try 60 seconds for a test.

The BOSH logs fro the very beginning of your session would be also very helpful. There we can see some of the BOSH configuration of your server, like inactive value setting.

Here is described how to get the Bosh logs:
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…

  • Your stacktrace also mentions the SslStream class. Have you made some tests without HTTPS to exclude problems on the SSL
layer?
  • Do you have HTTP proxies between the client and the servers?
  • Is there a firewall? Have you tried to disable it? Many firewalls hook into sockets and SSL and can cause strange behavior.

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:
Page:  1  2  next
Forum: MatriX RSS