End of script output before headers

My web app works fine in the IDE but when deployed to Apache2, I get these 2 errors repeatedly (thousands) logged to /var/log/apache2/site-error.log

[Sat Jan 30 13:31:54.987127 2016] [cgi:error] [pid 14526] [client 10.10.0.82:64678] AH01215: Can’t use an undefined value as a symbol reference at /mnt/data/www/site/cgi-bin/app/app.cgi line 118., referer: https://site/cgi-bin/app/app.cgi
[Sat Jan 30 13:31:54.987269 2016] [cgi:error] [pid 14526] [client 10.10.0.82:64678] End of script output before headers: app.cgi, referer: https://site/cgi-bin/app/app.cgi

Line #118: print $sock $body;

No additional information in Apache’s error.log

I have

  1. successfully connected to MySQL from the web server using the credentials app.cgi is configured to use (and pulled data from the DB)
  2. zipped up the build files in a tar ball, used FileZilla (in Active mode) to copy the files to the server
  3. verified permission and ownership of all files and directories
  4. copied files/directories to the server using just FileZilla (in Active mode) – This is normally the method I use to update the files and haven’t had any issues in the past

I have a few other Xojo cgi apps running just fine on the same server. They also connect to the same MySQL server.

The app is successfully establishing a connection to the MySQL server as noted in the app’s log file. The app is rapidly respawning with the “undefined value” messages I noted above.

{"timestamp":1454189041,"num":0,"desc":"Database","msg":"Attempting to establish connection to SQL Server..."} {"timestamp":1454189041,"num":0,"desc":"Database","msg":"Connection successful"}

It sounds like the app is crashing. The “End of Script Output before headers” error means that the script didn’t get a response from the app itself.

I’d try putting some code in the App.UnhandledException event and write the stack and error info from the exception object with System.DebugLog.

Where does System.DebugLog write its output on Ubuntu? I haven’t been able to find anything in the traditional log files. I also added a line to write to the same log file I used for the MySQL (as noted above) and nothing appears there either.

[code] If error <> Nil Then
Dim type As String = Introspection.GetType(error).Name
System.DebugLog(type + EndOfLine + EndOfLine + Join(error.Stack, EndOfLine))
LogToFile(Error.ErrorNumber, type, Error.Message + EndOfLine + Join(error.Stack, EndOfLine))

End If
[/code]

http://documentation.xojo.com/index.php/System.DebugLog

Thanks Albin. The docs say [quote]On Linux, it prints the message to StdErr.[/quote] From what I can find, StdErr is simply output to the console. If that truly is the case, I get nothing which would mean I’m not receiving any UnhandledExeceptions. What else would be causing the

[Sat Jan 30 13:31:54.987127 2016] [cgi:error] [pid 14526] [client 10.10.0.82:64678] AH01215: Can't use an undefined value as a symbol reference at /mnt/data/www/site/cgi-bin/app/app.cgi line 118., referer: https://site/cgi-bin/app/app.cgi [Sat Jan 30 13:31:54.987269 2016] [cgi:error] [pid 14526] [client 10.10.0.82:64678] End of script output before headers: app.cgi, referer: https://site/cgi-bin/app/app.cgi
messages to scroll continuously in the apache2 error log?

Thought I had it resolved by updating e-CryptIt and compiling my app as 64-bit. That lasted all of about 3 mins. before the same thing occurred again. There are 7 of us using this app (trying to use it) so I don’t understand why it is having such a hard time. When running in the debugger, the app performs just fine but when deployed…
Any more thoughts on what is causing my app to run so dog dang slow?

Don’t make that assumption. Put code in App.UnhandledException and check for yourself.

The reason I say this is that running an app as a CGI app changes the behavior of StdOut, StdIn and StdErr, so that info is probably being redirected to a log file somewhere.

After upgrading the e-CryptIt engine and compiling for 64-bit on Linux, the errors have not returned but the app still exhibits the exact same symptoms. I have been working with the apache2 configuration for the site to log CGI errors to /var/log/apache2 but haven’t been able to get apache to create the file and log anything.
Tonight I figured I’d do a standalone build for OS X since I don’t run into any of the issues during debug. Multiple users can access the app without delay and I receive no crash. After building and running the app, I get the following from StdErr on my Mac. Not the foggiest about what it is but hope someone can shed some light. These repeat on the console.

[code]Feb 23 21:46:25 Tally[6207] : BadDataException

rbframework.dylib$2110
String_ToText
String.$ToText%y%s
_WebSupport.Split%A1s%ss
WebSource.Append%%o<WebSource>si8b
WebLabel.Event_RenderHTML%o<WebSource>%o<WebLabel>
WebControl.Event_RenderHTML%o<WebSource>%o<WebControl>
WebObject._Render%o<WebSource>%o<WebObject>i8
WebPage.Event_RenderHTML%o<WebSource>%o<WebPage>
WebView.Event_RenderHTML%o<WebSource>%o<WebView>
WebControl.Event_RenderHTML%o<WebSource>%o<WebControl>
WebObject._Render%o<WebSource>%o<WebObject>i8
WebSession._AddControl%%o<WebSession>o<WebControl>
WebSession.CurrentPage.Set%%o<WebSession>i4o<WebPage>
WebPage.Show%%o<WebPage>
pgMain.pgMain.ShowMain%%o<pgMain.pgMain>
pgMain.pgMain.Event_Open%%o<pgMain.pgMain>
WebView.Event_Open%%o<WebView>
WebControl.Event_Open%%o<WebControl>
WebObject._ExecuteEvent%b%o<WebObject>sA1v
WebControl._ExecuteEvent%b%o<WebControl>sA1v
WebControl.!_ExecuteEvent%b%ssA1v
WebControl.!_ExecuteEvent%b%ss
pgMain.pgMain.Constructor%%o<pgMain.pgMain>
Session.Session.pgMain%o<pgMain.pgMain>%o<Session.Session>
pgMain.pgMain%o<pgMain.pgMain>%
pgLogin.pgLogin.Timer1_Action%%o<pgLogin.pgLogin>o<WebTimer>
Delegate.IM_Invoke%%o<WebTimer>
AddHandler.Stub.29%%
WebTimer._ExecuteEvent%b%o<WebTimer>sA1v
WebControl.!_ExecuteEvent%b%ssA1v
WebSession._HandleEvent%%o<WebSession>so<_HTTPServer.HTTPRequestContext>
WebSession._HandleRequest%i8%o<WebSession>so<_HTTPServer.HTTPRequestContext>
WebApplication._HandleHTTPRequest%%o<WebApplication>o<_HTTPServer.HTTPRequestContext>
_HTTPServer.HTTPRequestThread.Event_Run%%o<_HTTPServer.HTTPRequestThread>
rbframework.dylib$1192
_pthread_body

Feb 23 21:46:25 Tally[6207] : BadDataException

rbframework.dylib$2110
String_ToText
String.$ToText%y%s
_WebSupport.Split%A1s%ss
WebSource.Append%%o<WebSource>si8b
WebLabel.Event_RenderHTML%o<WebSource>%o<WebLabel>
WebControl.Event_RenderHTML%o<WebSource>%o<WebControl>
WebObject._Render%o<WebSource>%o<WebObject>i8
WebPage.Event_RenderHTML%o<WebSource>%o<WebPage>
WebView.Event_RenderHTML%o<WebSource>%o<WebView>
WebControl.Event_RenderHTML%o<WebSource>%o<WebControl>
WebObject._Render%o<WebSource>%o<WebObject>i8
WebView._RenderOneChild%%o<WebView>o<WebControl>o<WebResponse>
WebView._RenderNewChildren%%o<WebView>o<WebResponse>
WebSession._CreateResponse%o<WebResponse>%o<WebSession>
WebSession._HandleEvent%%o<WebSession>so<_HTTPServer.HTTPRequestContext>
WebSession._HandleRequest%i8%o<WebSession>so<_HTTPServer.HTTPRequestContext>
WebApplication._HandleHTTPRequest%%o<WebApplication>o<_HTTPServer.HTTPRequestContext>
_HTTPServer.HTTPRequestThread.Event_Run%%o<_HTTPServer.HTTPRequestThread>
rbframework.dylib$1192
_pthread_body[/code]

I started a new conversation as BadDataException may or may not be related to the “End of script output before headers”

Replacing all .StringValue statements with DefineEncoding(rs.Field("account_name").StringValue,Encodings.UTF8) seems to have fixed the BadDataExceptions but the CGI built application is still running super dog slow. No errors or CGI script output so I have nothing to go off of.