I created a Sinatra app that uses Mechanize gem. It runs fine locally, but when I deploy it to Heroku it tells me
at=error code=H10 desc="App crashed" method=GET path="/" fwd="83.245.232.99" dyno= connect= service= status=503 bytes=
even for this minimized code:
require "sinatra"
require "rubygems"
require "mechanize"
get '/' do
"hi"
end
What is going wrong?
This is probably the reason.
HTTPClient defines a module named HTTP. By default Sinatra looks for Rack handlers with namespace names HTTP and WEBrick, in that order.
Since the HTTP namespace has been defined Sinatra actually thinks it's a Rack handler. I think this is a bug in Sinatra. It should check if the handler responds to run before using it.
Anyway the fix is to use Thin, or if you want to use WEBrick then explicitly tell Sinatra to skip the automatic Rack detection by doing:
set :server, 'webrick'
That will prevent Sinatra from thinking the HTTPClient HTTP module is Rack handler.
Got it from here
For some reason it requires
set :server, 'webrick'
in my app.rb to run with Mechanize without error.
Related
I have a classic Sinatra app which at some point just stopped redirecting http requests to https. (I'm not sure when it stopped automatically redirecting, perhaps in the last year or so when I upgraded some things including the Sinatra gem to v 2.2)
The Gemfile.lock has:
rack-ssl (1.4.1)
The app initialization contains:
require 'rack/ssl'
use Rack::SSL
None of that has changed in my code.
But currently, if I navigate to http://www.myapp.com it stays on http, instead of redirecting to https like it used to.
I've also tried adding
set :force_ssl, true
But that had no effect.
I am running Nightscout on Heroku with an Atlas db. My phone apps are not sending data to nightscout successfully. I was told that there is something wrong on the server side and the issue is highlighted on the screenshot. I'd be grateful to anyone who can help. I'm not technical. The offending section appears to be:
2020-08-28T22:14:20.950759+00:00 app[web.1]: Error inserting the device status object user is not allowed to do action [insert] on [heroku_5c31xmqr.devicestatus]
2020-08-28T22:14:22.360826+00:00 heroku[router]: at=info method=POST path="/api/v1/devicestatus" host=johnsbgdata.herokuapp.com request_id=6776092e-3228-4c20-8a52-82e9c83576c7 fwd="3.11.203.168" dyno=web.1 connect=0ms service=10ms status=500 bytes=548 protocol=https
Error screen
Fixed this. It was a database permissions error. It was READ. When I changed it to READ/WRITE and restarted the dynos, it was fixed :)
The Problem
I am trying to host a simple HTTP server written in Rust on Heroku.
I am not using an external HTTP library because this is a learning project for University, so I am managing everything through TcpStreams.
The server works as expected locally.
I keep seeing the H18 (Server Request Interrupted) error in the Heroku logs, and the running instance on Heroku does not serve any files. Specifically, these types of errors occur:
2017-03-12T14:11:53.952084+00:00 heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=GET path="/" host=regans-rust-project.herokuapp.com request_id=fe50b113-8091-4129-99f5-632c9536bb8e fwd="154.126.208.8" dyno=web.1 connect=0ms service=2ms status=503 bytes=581 protocol=https
2017-03-12T14:11:54.459277+00:00 heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=GET path="/favicon.ico" host=regans-rust-project.herokuapp.com request_id=cf6ad8a0-2780-4c07-843a-2b533df1c9aa fwd="154.126.208.8" dyno=web.1 connect=0ms service=1ms status=503 bytes=388 protocol=https
What I have tried
I have made sure that the static resources are in the directory by invoking Heroku's bash utility. I have also run the executable from here, and the server works locally from the Heroku instance as well.
I have ensured that I am returning well-formed HTTP responses (I have status codes, content types, connection types, content lengths).
My Code
You can see my code here.
I am using the following buildpack
Is there anything else I should be appending to my responses to "finish" them? Any help would be greatly appreciated :)
As discussed in the comments, the problem was that the code was using \n as the delimiter in the HTTP response whereas the standard says it should be \r\n
I also faced this error testing a POST call to process the image file at Flask server.
I added a simple delay before returning the response
time.sleep(3)
It worked!
I believe Heroku(a free subscription) needs time to process the POST request from infrastructure angle, so it was throwing the network error if you return immediately
Before
#app.route("/process_image", methods=['POST'])
def process_image():
print ("received ")
return json.dumps({'success': True}), 200, {'ContentType': 'application/json'}
Later
#app.route("/process_image", methods=['POST'])
def process_image():
print ("received ")
time.sleep(3)
return json.dumps({'success': True}), 200, {'ContentType': 'application/json'}
I have an app ( smooch) running over Heroku. But for a while now I have had it return error 503's at me. I have no idea. It says he is looking for a favicon but in vain. No matter what I do noting is helping.
So firstly: I have used Heroku Belt on my mac and saw this msg - though the deploy was ok and got a green checkbox - so rather weird:
016-10-10T22:19:29.206225+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=independerchat.herokuapp.com request_id=a5c658c2-7ba3-413e-b81d-d80864b8fccf fwd="213.46.87.171" dyno= connect= service= status=503 bytes=
Secondly also did a rollback but that did not help either.
And lastly it has been around for a good week now......
Any help would be greately appreciated!
Thanks!
Wouter
#philippe_b is correct. smooch-bot-example an express app, so your best bet to resolve this issue would be to simply serve a favicon. I recommend using https://www.npmjs.com/package/serve-favicon
npm install serve-favicon
and in app.js:
app.use(favicon(__dirname + '/public/yourfavicon.ico'));
Edit: If you don't have a favicon you can generate one at RealFaviconGenerator.net ;)
I install Redmine on Heroku host, after solving some erorrs with gems, everything seems to be working. Except one small thing, when i click "My account", there is "internal error" with code 500.
I didn't see anything interesting in logs. Redmine was installed from windows 7 machine. If you can, pleas write reply easy to understand for newbie, or even step by step instruction. It's my totally first time doing something on server, and I need everything working for tomorrow. Thanks in advance.
Logs from heroku log console. Is there any other?
2016-07-19T17:27:28.502527+00:00 app[web.1]: Started GET "/my/account" for 81.190.76.211 at 2016-07-19 17:27:28 +0000
2016-07-19T17:27:28.511962+00:00 app[web.1]: Processing by MyController#account as HTML
2016-07-19T17:27:28.535131+00:00 heroku[router]: at=info method=GET path="/my/account" host=rgredmine.herokuapp.com request_id=b3eb89ba-2a4b-46d1-949a-b5d24f7b266f fwd="81.190.76.211" dyno=web.1 connect=1ms service=43ms status=500 bytes=968