Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
maincoon #1
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: agsXMPP application crashes unexpectedly when using invalid BOSH proxy
Application just silently closed even in debug mode. I've started application without debug and got this in system logs (System Tools->Event Viewer->Windows Logs->Application):

Application: SJ.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.WebException
Stack:
   at System.Net.ServicePoint.ConnectSocketCallback(System.IAsyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr)
   at System.Net.ContextAwareResult.Complete(IntPtr)
   at System.Net.Sockets.Socket.ConnectCallback()
   at System.Net.Sockets.Socket.RegisteredWaitCallback(System.Object, Boolean)
   at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(System.Object, Boolean)

This exception raised somewhere in agsXMPP component while calling Open and using invalid (ie unavailable) BOSH proxy settings. It raised after connect timeout as I understood. The problem is that I can not handle this exception since it's raising in parallel thread.
Any suggestions how to fix this?
Avatar
maincoon #2
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
Could be usefull. This stack trace I've got using WinDebug tools.


System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>SJ.exe</AppDomain><Exception><ExceptionType>System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Unable to connect to the remote server</Message><StackTrace>   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext&amp;amp; context)
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
   at agsXMPP.net.BoshClientSocket.OnGetSessionRequestStream(IAsyncResult ar)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.HttpWebRequest.SetResponse(Exception E)
   at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
   at System.Net.Connection.CompleteConnectionWrapper(Object request, Object state)
   at System.Net.PooledStream.ConnectionCallback(Object owningObject, Exception e, Socket socket, IPAddress address)
   at System.Net.ServicePoint.ConnectSocketCallback(IAsyncResult asyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.Sockets.Socket.ConnectCallback()
   at System.Net.Sockets.Socket.RegisteredWaitCallback(Object state, Boolean timedOut)
   at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)</StackTrace><ExceptionString>System.Net.WebException: Unable to connect to the remote server ---&amp;gt; System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 82.151.143.246:80
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp;amp; socket, IPAddress&amp;amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp;amp; exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext&amp;amp; context)
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
   at agsXMPP.net.BoshClientSocket.OnGetSessionRequestStream(IAsyncResult ar)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.HttpWebRequest.SetResponse(Exception E)
   at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
   at System.Net.Connection.CompleteConnectionWrapper(Object request, Object state)
   at System.Net.PooledStream.ConnectionCallback(Object owningObject, Exception e, Socket socket, IPAddress address)
   at System.Net.ServicePoint.ConnectSocketCallback(IAsyncResult asyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.Sockets.Socket.ConnectCallback()
   at System.Net.Sockets.Socket.RegisteredWaitCallback(Object state, Boolean timedOut)
   at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)</ExceptionString><InnerException><ExceptionType>System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 82.151.143.246:80</Message><StackTrace>   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp;amp; socket, IPAddress&amp;amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp;amp; exception)</StackTrace><ExceptionString>System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 82.151.143.246:80
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp;amp; socket, IPAddress&amp;amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp;amp; exception)</ExceptionString><NativeErrorCode>274C</NativeErrorCode></InnerException></Exception></TraceRecord>
(10a0.b44): CLR exception - code e0434352 (!!! second chance !!!)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\system32\KERNELBASE.dll -
Avatar
Alex #3
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I have commited a patch so SVN. Can you please check if this solves your problem?

Thanks,
Alex
Avatar
maincoon #4
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
Should work. I've made almost same modification yesterday by myself but I'm not sure about Disconnect() call inside "catch" section. Also You have same problem in BoshClientSocket::OnGetSessionRequestResponse(IAsyncResult result) - this exception rises when proxy do not accpet authorization (The remote server returned an error: (401) Unauthorized):

   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at agsXMPP.Net.BoshClientSocket.OnGetSessionRequestResponse(IAsyncResult result) in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 449
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.HttpWebRequest.ProcessResponse()

By the way. Do you interesting in SOCKS5 support? I've made some addons to agsXMPP and it works pretty fine. I could send you diff's or something like this.
Avatar
maincoon #5
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #3
Well. and another one there:

   at agsXMPP.Net.BoshClientSocket.BuildPostData() in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 632
   at agsXMPP.Net.BoshClientSocket.StartWebRequest(Boolean retry, String content) in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 699
   at agsXMPP.Net.BoshClientSocket.StartWebRequest() in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 678
   at agsXMPP.Net.BoshClientSocket.Request() in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 619
   at agsXMPP.Net.BoshClientSocket.CheckDoRequest() in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 613
   at agsXMPP.Net.BoshClientSocket.Send(String data) in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 600
   at agsXMPP.XmppConnection.Send(String xml) in C:\Work\argXMPP\XmppConnection.cs:line 383
   at agsXMPP.XmppConnection.Close() in C:\Work\argXMPP\XmppConnection.cs:line 413
   at SJ.MainWindow.XMPPClose(SJXmppClientConnection xmpp) in C:\Work\SecureJabber\SJ\Windows\MainWindow.xaml.cs:line 1744
   at SJ.MainWindow.GoOffline(SJXmppClientConnection xmpp, Boolean saveRoster) in C:\Work\SecureJabber\SJ\Windows\MainWindow.xaml.cs:line 461
   at SJ.MainWindow.<>c__DisplayClass15.<client_OnSocketError>b__14() in C:\Work\SecureJabber\SJ\Windows\MainWindow.xaml.cs:line 725
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

Line numbers are not same (because of my modification) but the reason is CurrentKeyIdx==-1 inside BuildPostData call, so there is "Index was outside the bounds of the array." exception was raised.
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #4
Quote by maincoon:
Should work. I've made almost same modification yesterday by myself but I'm not sure about Disconnect() call inside "catch" section.
yes I think the Disconnect can be removed.

Quote by maincoon:
Also You have same problem in BoshClientSocket::OnGetSessionRequestResponse(IAsyncResult result) - this exception rises when proxy do not accpet authorization (The remote server returned an error: (401) Unauthorized):

   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at agsXMPP.Net.BoshClientSocket.OnGetSessionRequestResponse(IAsyncResult result) in C:\Work\argXMPP\Net\BoshClientSocket.cs:line 449
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.HttpWebRequest.ProcessResponse()


There is not much error handling in the BoshSocket at all. To make it reliable there must be added lots of error handling.

Quote by maincoon:
By the way. Do you interesting in SOCKS5 support? I've made some addons to agsXMPP and it works pretty fine. I could send you diff's or something like this.

this is an open source project, so I am always interested at patches and extensions.

Alex
Avatar
maincoon #7
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
OK than.
I'll fix some other things in BOSH and finalize Socks5 then send diffs to You.
Thanx.
Avatar
maincoon #8
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #6
Here is patch for SVN version.
socks5 support added (works fine with ssl also) and some minor fixes for BOSH proxy - http://pastebin.com/6ss2uKHT
This post was edited on 2011-07-05, 14:10 by maincoon.
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Thanks for the patch. I take a look at it ASAP.

Alex
Avatar
maincoon #10
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
Here is correct patch for version 129. Patch also contains code for HTTP CONNECT proxy type support.
http://pastebin.com/eBnrjXAN
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