3

I'm struggling with the .NET alternative mono for Linux. Here is my meta data:

OS: Debian 7.6 alias Wheezy   (as virtual machine; host: Windows 7 Pro SP1)
nginx v1.6.1                  (installed from nginx repository)
mono v3.6.0                   (compiled from source)
mono-fastcgi-server4          (installed from Debian repositories)

nginx works properly; I tested it without mono, so that shouldn't be the problem.

The problem occurs when I enable the fastcgi part within nginxserver config: I get a 502 Bad Gateway.

For your information, these are all the config files I edited so far. I think these are the important ones:

/etc/nginx/conf.d/default.conf

server {
   listen        80;
   server_name   myserver.net;
   root          /var/www/myserver.net;
   index         index.html;

      location / {
         fastcgi_index   index.html;
         fastcgi_pass    127.0.0.1:9000;
         include         /etc/nginx/fastcgi_params;
      }
}

/etc/nginx/fastcgi_params (original except these two lines):

fastcgi_param PATH_INFO          "";
fastcgi_param SCRIPT_FILENAME    $document_root$fastcgi_script_name;

/etc/init.d/mono-fastcgi/myserver.net.webapp

<apps>
<web-application>
   <name>myserver.net</name>
   <vhost>*</vhost>
   <vport>80</vport>
   <vpath>/</vpath>
   <path>/var/www/myerver.net/</path>
</web-application>
</apps>

mono-fastcgi-server4 startup-command (split to multiple lines for overview)

fastcgi-mono-server4
  --appconfigdir /etc/init.d/mono-fastcgi
  /socket=tcp:127.0.0.1:9000
  /logfile=/var/log/mono/fastcgi.log &

I actually don't know, why the & has to be there at the end, but without it, the command won't work. Any suggestions?

I think this is all information I can share with you. If something is missing, please point it out, and I'll add the information ASAP.

EDIT: I forgot to add the fastcgi.log and nginx-logs:

/var/log/mono/fastcgi.log

[2014-09-04 10:39:20Z] Error   ERROR PROCESSING REQUEST: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.WebServer.FastCgi.WorkerRequest

Server stack trace: 
  at Mono.WebServer.FastCgi.ApplicationHost.ProcessRequest (Mono.WebServer.FastCgi.Responder responder) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper xdomain-dispatch) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (object,byte[]&,byte[]&)

Exception rethrown at [0]: 
 ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.FastCgi.WorkerRequest..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at (wrapper xdomain-invoke) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at Mono.WebServer.FastCgi.Responder.Process () [0x00000] in <filename unknown>:0 
[2014-09-04 10:39:20Z] Error   Failed to process connection. Reason: The object was used after being disposed.
[2014-09-04 10:39:20Z] Notice  Beginning to receive records on connection.
[2014-09-04 10:39:20Z] Error   ERROR PROCESSING REQUEST: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.WebServer.FastCgi.WorkerRequest

Server stack trace: 
  at Mono.WebServer.FastCgi.ApplicationHost.ProcessRequest (Mono.WebServer.FastCgi.Responder responder) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper xdomain-dispatch) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (object,byte[]&,byte[]&)

Exception rethrown at [0]: 
 ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.FastCgi.WorkerRequest..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at (wrapper xdomain-invoke) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at Mono.WebServer.FastCgi.Responder.Process () [0x00000] in <filename unknown>:0 
[2014-09-04 10:39:20Z] Error   Failed to process connection. Reason: The object was used after being disposed.

/var/log/nginx/access.log

10.0.2.147 - - [04/Sep/2014:10:39:20 +0200] "GET /default.aspx HTTP/1.1" 502 574 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36" "-"
10.0.2.147 - - [04/Sep/2014:10:39:20 +0200] "GET /favicon.ico HTTP/1.1" 502 574 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36" "-"

/var/www/nginx/error.log

2014/09/04 10:39:20 [error] 2928#0: *11 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 10.0.2.147, server: lexekon.net, request: "GET /default.aspx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "lexekon.net"
2014/09/04 10:39:20 [error] 2928#0: *11 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 10.0.2.147, server: lexekon.net, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "lexekon.net"
Eglain
  • 31
  • 3
  • Just a doubt: Does `fastcgi-mono-server4` support mono 3.6? Mono 3.6 seems to be .NET 4.5. – Jerry Bian Sep 04 '14 at 08:32
  • I don't think, that's the problem because I cannot even acces an html page. Imho, the fastsgi-server should ignore html pages, shouldn't it? – Eglain Sep 04 '14 at 09:15
  • I am now having the same issue after upgrading mono from 2.8.10 to 3.10 without changing anything else, so it is a version mismatch between fastcgi-mono-server4 and mono 3.6 – Marek Dec 08 '14 at 08:27

0 Answers0