Nginx + Passenger - Uncaught exception in PassengerServer client thread - ruby-on-rails

I've installed Passenger with Nginx for testing here and I keep getting this error after some thousand requests:
[ pid=57259 thr=0x40f07780 file=ext/nginx/HelperAgent.cpp:576 time=2010-12-15 14:04:25.876 ]: Uncaught exception in PassengerServer client thread:
exception: write() failed: Socket is not connected (57)
backtrace:
in 'void Client::forwardResponse(Passenger::SessionPtr&, Passenger::FileDescriptor&)' (HelperAgent.cpp:368)
in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:502)
in 'void Client::threadMain()' (HelperAgent.cpp:595)
[ pid=57259 thr=0x40f07080 file=ext/nginx/HelperAgent.cpp:566 time=2010-12-15 14:04:26.416 ]: Couldn't forward the HTTP response back to the HTTP client: It seems the user clicked on the 'Stop' button in his browser.
I have 2 servers, and I was running haproxy+apache+mongrel on them, I switched one of them for haproxy+nginx+passenger (haproxy is only a backup for my testing, so I can redirect to the old schema quickly in case of fire).
So I noticed that my passenger dies after this message.
Im using ruby-ee 1.8.7, rails 2.3.5 and FreeBSD.

That turns out to be a FreeBSD kernel bug. We're slowly putting more workarounds in the Phusion Passenger codebase to work around this.

Related

2241 illegal hardware instruction rails s

Here's the problem: Unable to start an existing Rails project after upgrading to MacOS 10.15.1. The terminal shows this (below) after Rails s and going to localhost:3000.
SEGV received in SEGV handler [1]
1438 illegal hardware instruction rails s
Note: The latest version of Xcode / command line is installed.
After upgrading the OS successfully (MacOS 10.15.1), I followed the MacPorts migration guide successfully. Further, I successfully reinstalled RVM with Ruby 2.6.1, 2.6.3 and 2.6.5.
Next, installed gem Rails -v 5.2.3 without issue. Tested this out with Rails new TestProj, it created a new project successfully, bundled and started the server with Rails s. No issues and saw the "Yay you're on Rails" page. So far so good.
Then I CD into an existing Rails project, which was built on MacOS 10.14.x (Mojave) did a bundle update without any issues. Followed by a rails s, Puma started without issue. Here's where it gets strange, literally the second I goto the URL "localhost:3000" I immediately get this error.
SEGV received in SEGV handler [1] <- this repeated
1438 illegal hardware instruction rails s
I thought it might be a gem issue, tried installing the same gem set into the TestProj and everything work perfectly with a Puma starting and loading "Yay...". Finally, I've tried cloning the repo, bundling and I get the same error message. I'm pasting what I believe is the most important part of the log file into this post. I wonder if there is something in the Rails app that specifies certain hardware that needs updating? My apologies for its length, Hopefully, someone can interpret this better than I can and help troubleshoot. I'm happy to provide more information. Just not sure what else besides the log file you might need. Let me know. Thanks!
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000000f8
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: ruby [1438]
VM Regions Near 0xf8:
-->
__TEXT 0000000103679000-000000010367a000 [ 4K] r-x/r-x SM=COW /Users/USER/*
Application Specific Information:
abort() called
Thread 11 Crashed:: thread_pool.rb*
0 libsystem_pthread.dylib 0x00007fff681ac65f pthread_kill + 276
1 libsystem_c.dylib 0x00007fff68077a1c abort + 120
2 libruby.2.6.dylib 0x00000001038261d9 ruby_abort + 9
3 libruby.2.6.dylib 0x0000000103826160 check_reserved_signal_ + 160 (signal.c:854)
4 libruby.2.6.dylib 0x0000000103825fa4 sigsegv + 36 (signal.c:997)
5 libsystem_platform.dylib 0x00007fff681a1b1d _sigtramp + 29
6 ??? 000000000000000000 0 + 0
7 libsystem_c.dylib 0x00007fff68077a1c abort + 120
I expect to cd into the existing RoR application and run rails s to start the server. Then go to http://localhost:3000 and see the application without crashing. The actual results are the following:
...
SEGV received in SEGV handler
SEGV received in SEGV handler
SEGV received in SEGV handler
SEGV received in SEGV handler
SEGV received in SEGV handler
SEGV received in SEGV handler
SEGV received in SEGV handler
SEGV received in SEGV handler
[1] 16523 illegal hardware instruction rails s

Exception RuntimeError in Passenger RequestHandler's client socket (can't modify string; temporarily locked)

Receiving below error on rails application hosted on nginx:
Sending 502 response: application did not send a complete response
App 1462 stderr: [ 2015-xx-xx 15:10:29.2082 1494/XXXXXXXXXXXX(Worker 1) utils.rb:85 ]: *** Exception RuntimeError in Passenger RequestHandler's client socket (can't modify string; temporarily locked) (process 1494, thread XXXXXXXXXXXXX(Worker 1)):
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/utils/unseekable_socket.rb:188:in `read'
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/utils/unseekable_socket.rb:188:in `read'
[ 2015-09-09 15:10:29.2083 1423/7fa8af7fe700 age/Cor/Req/Utils.cpp:95 ]: [Client 6-19] Sending 502 response: application did not send a complete response
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/message_channel.rb:177:in `read_scalar'
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/request_handler/thread_handler.rb:217:in `parse_session_request'
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger
Restarted VM and application but receiving same error.
Not sure what exactly causes this error. But as can be found from this link:
http://code.google.com/p/phusion-passenger/issues/detail?id=582
We reuse the same buffer over and over for receiving request data, for performance reasons. If your app is somehow able to use our buffer for receiving I/O data as well, in a different thread, then that would result in a race condition with the reporter error as a result.
One user reports resolution of similar problem here:
http://code.google.com/p/phusion-passenger/issues/detail?id=605
Indeed, I've narrowed it down to rails-master and/or rack-cache 1.0. When removing caching from latest version of rails (so it does not load rack-cache) everything works.
Hope it will be helpful

fitbit Oauth ssl connection error

I've moved my server with another provider, my app was working without issue until I made the migration, now everytime I try to connect with fitbit I get this error:
Fatal error: Uncaught exception 'OAuthException' with message 'making the request failed (SSL connect error)' in /var/www/html/includes/fitbitphp.php:188 Stack trace: #0 /var/www/html/includes/fitbitphp.php(188): OAuth->getRequestToken('https://api.fit...', 'https://gtefina...') #1 /var/www/html/fitbit.php(26): FitBitPHP->initSession('https://gtefina...') #2 {main} thrown in /var/www/html/includes/fitbitphp.php on line 188
I'm using this class as a wrapper https://github.com/heyitspavel/fitbitphp
I've been looking around in several configs of the server but I ran out of options, any idea?
thank you.
You most likely need to update your root CA (Certification Authority) on your new web server.

Apache with passenger gives error(Premature end of script headers) in development mode

I'm using Apache + passenger for my rails application, The application is running fine in production mode except when the browser displays error message after every 2-3 clicks in development mode which goes off when i refresh the page.I'm using metal in my rails application which i see could be the reason but not sure if it is the only reason.
Error message on browser:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.16 (Ubuntu) Server at localhost Port 80
Apache log Error:
[Thu Dec 01 16:55:23 2011] [error] [client 127.0.0.1] Premature end of script headers: view_transactions, referer: http://localhost/admin_portal/1014978061/view_transactions
[ pid=660 thr=3078097552 file=ext/apache2/Hooks.cpp:822 time=2011-12-01 16:55:23.563 ]: The backend application (process 796) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application.
[ pid=796 thr=-608495398 file=utils.rb:176 time=2011-12-01 11:25:23.878 ]: *** Exception NoMethodError in application (undefined method `new' for Rails:Module) (process 796, thread #<Thread:0xb77631b4>):
from /home/brijendra/aptana_studio_3_workspace/wantsa/vendor/plugins/newrelic_rpm/lib/new_relic/control.rb:467:in `new_instance'
from /home/brijendra/aptana_studio_3_workspace/wantsa/vendor/plugins/newrelic_rpm/lib/new_relic/control.rb:54:in `instance'
from /home/brijendra/aptana_studio_3_workspace/wantsa/vendor/plugins/newrelic_rpm/lib/new_relic/agent.rb:167:in `logger'
I would be eager to post any other output if required and also suggestions to fix this issue.
I fixed this error by changing cache as true in my development.rb and it worked fine.

Rails app may be crashing passenger, not sure how to debug?

My app generates some image data on the fly and sends it back to the browser with send_data some_huge_blob, :type => 'image/png'. This works well enough in development mode, but in production with nginx/passenger in the mix it appears as if sometimes passenger just crashes. Here is the debug output in my nginx log
[ pid=596 thr=140172782794496 file=ext/common/ApplicationPool/Pool.h:1162 time=2011-07-25 23:15:14.965 ]: Exception occurred while connecting to checked out process 1428: Cannot connect to Unix socket '/tmp/passenger.1.0.589/generation-0/backends/ruby.kJRjXYuZteKoogZIufN8a2cDPdpbIlYmIr1hh3G9UV7GhKDB4pqZ5y0jR': Connection refused (111)
[ pid=596 thr=140172782794496 file=ext/common/ApplicationPool/Pool.h:685 time=2011-07-25 23:15:14.965 ]: Detaching process 1428
[ pid=596 thr=140172782794496 file=ext/common/ApplicationPool/../Process.h:138 time=2011-07-25 23:15:14.969 ]: Application process 1428 (0x2676ee0): destroyed.
[ pid=1405 thr=70178806733240 file=abstract_request_handler.rb:466 time=2011-07-25 23:15:14.982 ]: Accepting new request on main socket
2011/07/25 23:15:16 [error] 642#0: *96 upstream prematurely closed connection while reading response header from upstream, client: 173.8.216.57, server: app.somedomain.com, request: "GET /projects/4e2dee4c106a821bf2000008/revisions/1/assets/Layout2.psd/preview HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "app.somedomain.com"
Note that there is nothing in my production.log file that indicates the request even makes it to the app!
Any ideas? Or ideas as to how to debug this further? The connection refused bit is interesting...
For what it's worth, this is an Ubuntu image on a micro instance in AWS.

Resources