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'}
Related
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 :)
We use Capybara along with Chrome Headless for integration testing. I'd like to write a linter, that checks some metrics on the HTML structure everytime chrome navigates to another page. Then I'd raise an error when something is against our linter.
We have some tests without javascript, and monkey patching rack-test works so far:
Capybara::RackTest::Browser.class_eval do
alias_method :process_orig, :process
def process *args
response = process_orig *args
# do some linting
response
end
end
But I haven't found a way inside Capybara and/or Chrome Headless where I could intercept a response, and check the body of the page.
Is it possible to trigger a hook, when a page changes? Or is there some kind of API Chrome provides where I could get the body of every request? Or would a proxy be a feasible solution?
This isn't possible directly with Capybara, since it doesn't actually know about page transitions/requests that happen in the browser unless they are specifically user initiated with visit.
A potential way to do what you want would be using a programmable proxy like puffing-billy to handle every request to the app under test. If you use puffing-billy you'll want to look at the pass_request feature - https://github.com/oesmith/puffing-billy#in-your-tests-capybarawatir - to forward on the initial request and then do whatever you want with the response.
I'd not tangle capybara tests with HTML linting. It may seem smart at this moment, as you get a list of URL's to check for free with each test, but:
You'd probably lint each URL few times because some tests go through it
You might get failures because HTML is not perfect, even though the feature you're testing is actually ok.
You probably have something like sitemap.xml or other sources of all available URLs. I'd use it to make a separate check, which will be simple: request the URL, lint the response. Rinse and repeat.
If still not convinced, try using page.html and do sth like
expect(page.html).to pass_linter
https://github.com/teamcapybara/capybara#debugging
You can then add it as an around hook for every type: :feature spec if you want.
EDIT: here's another workaround to have every visited path. Just parse the server log file (like this cat log/devlopment.log | grep path) to get a full list if visited paths:
method=POST path=/users/login format=html controller=SessionsController action=create
status=302 duration=256.82 view=0.00 db=52.29 location=http://0.0.0.0:3000/platform/admin/dashboard params={"utf8"=>"✓", "authenticity_token"=>"ubGnWKOq8gbUE5C/aK375QQn5DpjHarUYxHtBLglGe6Lr9Ie3O5XPq90k5gr/SZbIPoDiiasvY0mGlwhzD/MsQ==", "user"=>{"email"=>"alex-3d51048235c9d1a8#toptal.io", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"} uid=983 remote_ip=127.0.0.1 x_forwarded_for= x_request_id=
method=GET path=/admin/dashboard format=html controller=XXX action=show status=200 duration=3285.54 view=1051.32 db=2016.87 params={} uid=983 remote_ip=127.0.0.1 x_forwarded_for= x_request_id=
and use it for linting.
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
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.