Incomplete response from application - ruby-on-rails

I'm getting 'Incomplete response received from application' when testing my rails application. It disappears when I refresh the page..
I check my apache error logs and I found this line:
[ W 2018-08-06 07:55:32.1636 126806/T8 age/Cor/Con/InternalUtils.cpp:96 ]: [Client 1-4] Sending 502 response: application did not send a complete response
Any one faced the same issue ?

This issue has some history. Best you can do is add some debug to your application.
This happens when your application exits prematurely. To understand what this means, consider that Passenger works by sitting between the client and the app. Passenger acts like a reverse proxy, so it forwards the request to your app, then processes the response that the app sends.
client <-----> Passenger <-----> app
If, after Passenger has sent the request, the app crashes or otherwise exits before sending a response, then you will see "application did not send a complete response".
So the question is actually: why does the application exit? Unfortunately I do not know, and neither does Passenger. Passenger only starts your app and expects your app to respond to requests as normal. Maybe there is a bug in the app, or the app encountered some sort of fatal error. Normally the app will print an error message when that happens, but Passenger did not encounter any such messages, or it would have printed them.
So the best thing I can recommend you to do is that you insert debugging statements inside your app and find out what makes it exit.

Related

QuickFIX/J session hangs when using SSL and proxy

I am facing a strange problem. After a variable amount of time, my quickfixj session simply hangs without any error. The session seems to be locked because I cannot write anything to it (without exceptions on the log file) nor the server sends anything to me. The thread socket initiator shows that the sessions is logged in, but I cannot write anything on the socket because it seems to be locked.
Any suggestions?

Rails server keeps crashing without any logs when deployed to AWS with capistrano

So, I deployed my rails app to AWS using Capistrano, the API's are called using an iOS App written in swift 4.
When the iOS App is launched, it makes 4-5 API calls, to fetch and update data onto the rails App. When these calls are made individually using a REST Client they all succeed without any issues. But when they are made simultaneously in the background of the iOS App, the server stops responding after 2 or 3 are done successfully. Funnily, this works perfectly when the rails server is run on my local machine (MacBook Pro).
I still have no idea what causes the server to stop responding, I check the logs, it ends on the last API call where it stops responding
Started GET "/api/v1/trendings" for XX.XXX.XXX.XX at 2018-06-30 07:44:32 +0000
The last line of my log
Please, give me more information about that error.
What server are you using? (i.e: nginx, puma, apache)
What OS on the server?
What http error code are returned by Rails app? (i.e: 401, 500 etc)
If you are using puma server, there is some problems while handling multiple requests from same origin as described here.
Regards.

How can I open a web socket with Sails.JS without using a browser?

I have been trying to open a websocket from iOS with an API developed in Sails.JS running on Heroku. But I am not sure where to point the web socket.
Attempting to connect directly to ws://my-domain.herokuapp.com fails with a 503 error every time.
What I have noticed, however, when opening my app in chrome, and monitor the console - I occasionally see this error in the console:
WebSocket connection to 'ws://my-domain.herokuapp.com/socket.io/1/websocket/2RNf_dS2sjcShe397tEQ' failed: Unexpected response code: 503
But almost immediately after, it connects. My question is: where is the socket path on that URL coming from? Is that something that Sails.JS issues upon an HTTP Connection, and is that something I should request in iOS? Or am I missing something else?
I would suggest taking a look at: https://github.com/balderdashy/sails-examples/tree/master/SampleAppiOS. Instead of using web sockets, it uses socket.io.

Detecting HTTP connection closure in Rails

When using Nginx there are times then HTTP 499 is recorded in the error log when the client has prematurely closed their connection (for example, the connection timed out, the user reloaded their browser or pressed Stop or otherwise).
I understand that Nginx is able to detect this because they are the end which will receive the SIGPIPE signal indicating the socket has been closed, however I am wondering if it is possible to get this notice back to Rails at all?
Shopify recently used a very novel approach to detect this in Unicorn before sending the request on to Rails to be processed, however I would like to be able to detect this within the Rails app, such as during a long-running transaction.
After Rails's dispatcher had already started processing the request - there is no connection to the http client anymore, only when the processing is done - the response is headed back to the client.
So basically, there is no way you can tell if the client (e.g: browser) had shutdown the connection while you are already processing it.

Unexplained heroku timeouts

I have a rails 3.2.11 app deployed on Heroku that has been fairly stable over time. In the last 24 hours, pingdom has been reporting Timeouts which I can't find any "H1X" related errors in the logs at the same time.
I am occassionally able to reproduce the timeouts in google chrome. where I would get this message after about 30 seconds of requesting any page:
Chrome browser error
No data received
Unable to load the webpage because the server sent no data.
Here are some suggestions:
Reload this webpage later.
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.
The app will then begin serving requests normally until it happens again.
I know this is not enough info, but I can't find anything useful yet in newrelic or scanning the logs that correlates to when the error occured.
In one instance, i was reproducing the error in the browser while viewing the heroku logs and when the timeout occurred, there was no evidence of the request showing up in the logs. Its like the failed requests never make it into the app.

Resources