0

I have a .NET 2.0 application which I'm interested in porting to run on Linux under mod_mono.

Part of the application is an XHR proxy which provides access to the various data-feeds provided to the front-end. This proxy script makes sure the user has a valid session, then makes sure the user is entitled to the data they're attempting to retrieve. Lastly, if requested, the proxy will convert the XML to JSON using Newtonsoft.

The URL for this service looks something like this:

/ApiProxy.aspx?url=http%3A%2F%2Fexample%2Fapi%2Fservice

For some reason I can't get this piece of software running under mod_mono. It produces the following error:

System.Threading.ThreadAbortException
Thread was being aborted
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
  at (wrapper managed-to-native) System.Threading.Thread:Abort_internal (System.Threading.InternalThread,object)
  at System.Threading.Thread.Abort (System.Object stateInfo) [0x00000] in <filename unknown>:0 
  at System.Web.HttpResponse.End () [0x00000] in <filename unknown>:0 
  at ASP.apiproxy_aspx.__RenderTree (System.Web.UI.HtmlTextWriter __output, System.Web.UI.Control parameterContainer) [0x00000] in <filename unknown>:0 

I really have no idea what to make of this error.

It doesn't seem to reference any of my code and doesn't provide any hints as to where the issue may lie. One clue I have is that there are some large blocks which seem to be related to the issue:

using(SqlConnection con = new SqlConnection(myConnectionString))
{
    con.Open();

    //1) determine if the user is allowed to get the service
    //2) retrieve the content the user is requesting
    //3) convert the content to json

    } catch (Exception ex){
        throw new Exception("Unhandled exception", ex);
    } finally {
        if(con != null)
            con.Close();
    }
}

When I comment out the try/catch/finally block the behavior changes a bit, but the end result is still an error. This time a naked 400 invalid request error.

I'm really not sure where to start here, so I guess I have two questions:

  1. What's causing this error?
  2. How can I get better diagnostic information?
zorlack
  • 664
  • 2
  • 7
  • 26

1 Answers1

1

The most possible cause is that you've got timeout while processing request. Increase timeout in web.config and error should go away.

<location path="apiproxy.aspx">
    <system.web>
        <httpRuntime executionTimeout="180"/> <!-- set large value here -->
    </system.web>
</location>

Here the code of HttpResponse.End () method in mono https://github.com/mono/mono/blob/master/mcs/class/System.Web/System.Web/HttpResponse.cs#L631-L638

    public void End ()
    {
        if (context == null)
            return;

        if (context.TimeoutPossible) {
            Thread.CurrentThread.Abort (FlagEnd.Value);
        } else {
Sergey Zhukov
  • 1,342
  • 1
  • 13
  • 24