HTTP Parse Errors coming from AirPlay - ruby-on-rails

I'm working on a fairly large Rails 3 project that by default is run on localhost:5000 for development. I'm currently migrating our web server from unicorn to puma. However, when I run my development server, I constantly get these kinds of errors:
16:11:39 web.1 | 2015-07-02 16:11:39 -0500: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
16:11:39 web.1 | 2015-07-02 16:11:39 -0500: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"txtAirPlay&txtRAOP", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.11.2", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/info", "REQUEST_URI"=>"/info?txtAirPlay&txtRAOP"}
16:11:39 web.1 | ---
Research indicates that this is because OS X Yosemite uses port 5000 for AirPlay streaming. I'm looking for a way to remove these errors from my stdout.
I can't figure out if there's a way to disable AirPlay temporarily, or even if I should be doing that.
I can't feasibly just change the port my application runs on - this is a fairly large project with a lot of contributors. Trying to just change the port locally sends me down a rabbit hole.
Is there a way to either silently reject these requests or just simply filter them from my stdout? I'm worried I'm missing important signals amongst this noise.

Related

Receive RTSP stream within docker container

I am trying to decode a camera rtsp stream using ffmpeg_libs within a ubuntu docker container. The ffmpeg debug output seems to show that it successfully negotiates the rtsp-digest authentication (ie. RTSP/1.0 200 OK), and receives an SPS (nalu 7) and PPS (nalu 8), but nothing after that. It times out, retries, etc. That doesn’t really make sense to me.
The same code compiled and run locally (not in docker) works fully.
Also, if I decode a file, the code works fine both locally and in docker container. So, the basic ffmpeg_lib decode is working. The difficulty is with the stream interface running in docker.
Is there additional authentication through the docker interface, or maybe port access, or something? I’m not much of a networking guy, so I’m really lost at this point.
The ffmpeg logs is below, and my docker run command is:
docker run -it --name VideoRx videorx:latest (also tried with -p 554)
Any help will be very much appreciated.
Thanks,
Wayne
avformat_version(): 3756900 Build: 3756900 Ident: Lavf57.83.100
avformat_open_input(): rtsp://admin:public_pwd#192.168.1.237
Probing rtsp score:100 size:0
[tcp # 0x56263b430a20] No default whitelist set
[rtsp # 0xaddr1] Sending:
OPTIONS rtsp://192.168.1.237:554 RTSP/1.0
... [snipped]
Initial authentication handshake (OPTIONS, DESCRIBE, SETUP).
All success, server replies: 'RTSP/1.0 200 OK'
....
[rtsp # 0xaddr1] Sending:
PLAY rtsp://192.168.1.237:554/ RTSP/1.0
Range: npt=0.000-
CSeq: 5
User-Agent: Lavf57.83.100
Session: 420467284
Authorization: Digest username="admin", realm="IP Camera(C1003)", nonce="129b254c8da4e0ffb530f64f79938bcd", uri="rtsp://192.168.1.237:554/", response="82c6c0f1fadea3739846866e8e50e855"
--
[rtsp # 0xaddr1] line='RTSP/1.0 200 OK'
[rtsp # 0xaddr1] line='CSeq: 5'
[rtsp # 0xaddr1] line='Session: 420467284'
[rtsp # 0xaddr1] line='RTP-Info: url=rtsp://192.168.1.237:554/trackID=1;seq=43938;rtptime=4022155312'
[rtsp # 0xaddr1] line='Date: Thu, Aug 02 2018 15:53:00 GMT'
[rtsp # 0xaddr1] line=''
avformat_open_input(): Success erc: 0
avformat_find_stream_info()
[h264 # 0xaddr2] nal_unit_type: 7, nal_ref_idc: 3
[h264 # 0xaddr2] nal_unit_type: 8, nal_ref_idc: 3
[rtsp # 0xaddr1] UDP timeout, retrying with TCP
[rtsp # 0xaddr1] ...
... Stalls waiting for additional packets

Getting websocket error code 1006 when trying to connect to Actioncable server

I'm building an app using Nativescript/Angular 2 and I'm also using a javascript library to use websockets connecting it with an Actioncable Rails app.
When trying to establish connection I get a websocket error code 1006 on the Nativescript log console and the connection gets closed.
I noticed that the initial HTTP (the handshake) request sends two values for Sec-WebSocket-Protocol on the header (actioncable-v1-json, actioncable-unsupported) but the headers in the response have only one value for Sec-WebSocket-Protocol which is 'actioncable-v1-json' and 'actioncable-unsupported' is missing.
I believe this error happens because of the missing protocol in the response.
Does anyone know how to add this header (actioncable-unsupported) to the handshake response? Or any other ideas of what is causing this error?
There is no error in the rails log, it just gets connected and then disconnected:
Started GET "/v1/cable/" [WebSocket] for 192.168.1.8 at 2017-04-02 17:04:06 -0700
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: upgrade, HTTP_UPGRADE: websocket)
Finished "/v1/cable/" [WebSocket] for 192.168.1.8 at 2017-04-02 17:04:06 -0700
The error message displayed on the Nativescript console is this:
CONSOLE LOG file:///app/tns_modules/nativescript-actioncable/lib/action_cable.js:46:33: [ActionCable] Opening WebSocket, current state is null, subprotocols: actioncable-v1-json,actioncable-unsupported 1491179483038
CONSOLE LOG file:///app/tns_modules/nativescript-actioncable/lib/action_cable.js:46:33: [ActionCable] ConnectionMonitor started. pollInterval = 3000 ms 1491179483042
CONSOLE LOG file:///app/tns_modules/nativescript-actioncable/lib/action_cable.js:46:33: [ActionCable] Socket was closed because: code: 1006 1491179483109
Thank you
I was having this issue and the issue was the cable.yml configuration.
We noticed that the staging environment had this value for url:
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
Removing that value and actually other values fixed it for us.
New cable.yml staging config:
staging:
adapter: redis
Working!

Puma server log error

I have an AngularJS web application sending requests to a Rails API running in a Puma server.
I see this error in my puma error log once or twice a day:
2015-02-26 23:26:41 +0000: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2015-02-26 23:26:41 +0000: ENV: {"rack.version"=>[1, 2], "rack.errors"=>#<File:/home/ubuntu/env/production/www/yanpyapi/log/puma.stderr.log>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.10.1", "GATEWAY_INTERFACE"=>"CGI/1.2"}
I guess I have something wrong in my code. Not sure. Any way to identify where?
it could be that you use somewhere ssl. in my example I used http://host.com(unsecure) and wss(secure) and it gave me that error. when they both match there is no error. so change it to http and ws or https and wss. Hope this is your case.
Any way to identify where?
Fork puma repository and add additional logging to methods called parse_error (try to log all request body). Use this way you can find request which caused your problem and investigate it.

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