I just spent a week upgrading rails to 4.2.10, and upgraded a whole bunch of gems and such, and now that I've finally convinced rails to run without errors, my app won't actually load.
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
I have no idea where to even start trying to debug this.
The development.log file doesn't have any errors. The entire file says:
^[[1m^[[36mAppConfiguration Load (0.5ms)^[[0m ^[[1mSELECT `configurations`.* FROM `configurations` WHERE `configurations`.`type` IN ('AppConfiguration') AND `configurations`.`name` = 'Default configuration' LIMIT 1^[[0m
Cache read: Spree::Config
Dalli::Server#connect memcached:11211
Cache fetch_hit: Spree::Config
Cache read: Spree::Config
Cache fetch_hit: Spree::Config
Cache read: Spree::Config
Cache fetch_hit: Spree::Config
And nothing new is printed when I hit the page.
docker-compose logs -f abc just says:
=> Booting WEBrick
=> Rails 4.2.10 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2018-08-17 14:48:01] INFO WEBrick 1.3.1
[2018-08-17 14:48:01] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux-gnu]
[2018-08-17 14:48:01] INFO WEBrick::HTTPServer#start: pid=18 port=3000
Would my Gemfile be useful? What else would helpful to share?
It's not a local browser issue, because curl responds with (52) Empty reply from server, as well.
In Firefox: The connection to the server was reset while the page was loading.
ETA: Solved by adding -b 0.0.0.0 at the end of bundle exec rails server
Related
I know that I can use logging to log all the requests that my django server gets. However I would like to log the requests along with headers and body that my django server makes to other servers. How can I access this info?
What type of logs do you really want?
1 - in development mode, you can get the request as .txt using: python manage.py runserver > logs.txt - source: stackoverflow
2 - The Apache2 webserver provides two important logs: error.log or access.log. If you are using debian/ubuntu, you can get it in?
/var/log/apache2/error.log or access.log
I am working on a flask-socketio server which is getting stuck in a state where only 504s (gateway timeout) are returned. We are using AWS ELB in front of the server. I was wondering if anyone wouldn't mind giving some tips as to how to debug this issue.
Other symptoms:
This problem does not occur consistently, but once it begins happening, only 504s are received from requests. Restarting the process seems to fix the issue.
When I run netstat -nt on the server, I see many entries with rec-q's of over 100 stuck in the CLOSE_WAIT state
When I run strace on the process, I only see select and clock_gettime
When I run tcpdump on the server, I can see the valid requests coming into the server
AWS health checks are coming back succesfully
EDIT:
I should also add two things:
flask-socketio's server is used for production (not gunicorn or uWSGI)
Python's daemonize function is used for daemonizing the app
It seemed that switching to gunicorn as the wsgi server fixed the problem. This legitimately might be an issue with the flask-socketio wsgi server.
I have a Django site that uses Gunicorn and Nginx. Occasionally, I'll have a problem that I need to debug. In the past, I would shut down Gunicorn and Nginx, go to my Django project directory and start the Django development server ("python ./manage.py runserver 0:8000"), and then restart Nginx. I could then insert set_trace() commands and do my debugging. When I fixed the problem I'd shut down Nginx and then restart Gunicorn and Nginx. I'm pretty sure this was working.
Recently, though, I've begun having problems. What happens now is that when I've stopped at a breakpoint, after a couple of minutes the web page that I've stopped on will change and display "404 Not Found" and if I take another step in the debugger, I'll see this error:
- Broken pipe from ('127.0.0.1', 43742)
This happens on my development, staging, and production servers which I'm accessing via their domain names, e.g. "web01.example.com" (not really example).
What is the correct way to debug my Django application on my remote servers?
Thanks.
I figured out the problem. First I observed that when I stopped at a breakpoint, the page always timed out after exactly one minute which suggested that the Nginx connection to the web server was timing out if the web server took more than 60 seconds to respond. I then found an Nginx proxy_read_timeout directive which defines this timeout. Then it was merely a matter of changing the length of the timeout in my Nginx config file:
# /etc/nginx/sites-enabled/example.conf
http {
server {
...
location #django {
...
# Set timeout to 1 hour
proxy_read_timeout 3600s;
...
}
...
}
}
Once you've made this change you need to reload Nginx, not restart it, in order to this change to take effect. Then you start Django as I indicated above and you can now debug your Django application without it timing out. Just be sure to remove the timeout setting when you're done debugging, reload Nginx again, and restart Gunicorn.
I folowed the rails tutorial org tuto and made a web site
Installed passenger, nginx. Works perfectly on prod env on heroku=>
http://klat.herokuapp.com/ (app not finished but still better than nothing)
Here i use the =>
config.force_ssl = true
(only for heroku)
my routes from routes.rb =>
Rails.application.routes.draw do
get 'users/new'
root 'static_pages#home'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
get 'contact' => 'static_pages#contact'
get 'login' => 'static_pages#login'
get 'signup' => 'users#new'
resources :users
end
~/.bash_profile and ~/.bashrc got
#a generated key
export SECRET_KEY_BASE="my_very_big_generated_key"
export SECRET_TOKEN="my_very_big_generated_key"
I generated with openssl my own certificates
ls ../cert/
server.crt server.csr server.key server.key.org server.pem
And I launch my server with this command in local
passenger start -p 2000 --ssl-certificate ../cert/server.csr --ssl-port 20001 -e production
I passed two days to get to this point but i can't find out why my server starts at
http ://0.0.0.0:2000/
and redirects at
https ://0.0.0.0:2000
and no one page is accessible: error
An error occurred during a connection to 0.0.0.0:2000. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)
But in logs we clearly see
App 12832 stdout:
App 12854 stdout:
App 12854 stdout: Started HEAD "/" for 127.0.0.1 at 2015-04-24 18:09:30 +0200
App 12854 stdout: Processing by StaticPagesController#home as HTML
{... rendering homepage wiht _header.erb _footer.erb etc ...}
So i can visit my website non rendered with css at address:
http: //127.0.0.1:2000/
and i still getting those messages from my nginx server
ActionController::RoutingError (No route matches [GET] "/images/rails.png"):
ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css"):
{...and more ...}
I commented in every file in my ruby on rails app all ssl_force
when i uncomment in config/production.rb
config.force_ssl = true
for local use, i get
on
http ://127.0.0.1:2000/ => redirect to https ://127.0.0.1:2000/ and get => (Error code: ssl_error_rx_record_too_long)
http ://127.0.0.1 => unable to locate
https ://127.0.0.1 => unable to locate
http ://127.0.0.1:2000 => unable to locate
http ://127.0.0.1:2001 => unable to locate
https ://127.0.0.1:2000 => unable to locate
https ://127.0.0.1:2001 => unable to locate
Just can't find out why my openssl generated keys don't work, the pages are not rendered with css and other ressources, it's maybe a routing problem...
A little help is much appreciated!
PS: (But please no help such as "use Thin or Puma or another server, i have a constraint to use at choice nginx, lighthttpd or Apache (the obvious answer is nginx for me)")
And to set up my own ssl certification in my own server is a constraint too in my studies
finally
the command i did to start my server without errors is
passenger start --ssl-certificate ../cert/server.crt --ssl-certificate-key ../cert/server.key -e production --ssl
without specifying the ssl port and standart port
i added
gem 'rack-ssl', :require => 'rack/ssl'
to my gem file
and did several bundle install/--deployment etc...
set up in production.rb
config.force_ssl = true
and in application_controller.rb
force_ssl
so my connection is encrypted now as i connect to
https://0.0.0.0:3000/
BUT...
I'm still unhappy with all those configurations because of the presence of the port number in the url
Anyway, it will do for now...
We have a nginx - gunicorn - django setup.
Server runs fine for a while and then nginx starts throwing
504 Gateway Time-outs.
Trying to access gunicorn locally (127.0.0.1:8000) with lynx does not work either.
Logging into the machine shows enough cpu, memory and disc space available:
CPU[|||| 3.3%]
Mem[|||||||||||||||||| 362/3750MB]
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 5.5G 2.1G 73% /
Supervisor shows gunicorn is running:
gunicorn RUNNING pid 25264, uptime 2 days, 8:55:22
The database that sits underneath django is alive.
I looked through the django, supervisor, nginx and database logs and I couldn't find anything (!) suspicious.
[Update: Logs]
In the nginx.error.logs there is a few
client intended to send too large body
SSL_do_handshake() failed
errors every now and then and for sure
upstream timed out
recv() failed (104: Connection reset by peer) while reading response header from upstream
errors after gunicorn got stuck.
Versions
nginx/1.6.2
gunicorn==18.0
Django==1.6.2
supervisor==3.0
Any recommendations how to find out what/why that's happening?
(restarting gunicorn via supervisor fixes the issue)