Angular and Rails with Paypal integration error - ruby-on-rails

I have a rails with angular application.
I already used web payment.especially pay-pal.
When i completed my payment with pay-pal.
I got this error
{"result":false,"msg":"Invalid API Token."}
In my rails console,
Started GET
"/api/v1/charges/paypal_payment?tx=8R95473028301340P&st=Completed&amt=20.00&cc=USD&cm=&item_number="
for 127.0.0.1 at 2016-08-30 11:12:03 +0530 Processing by
Api::V1::ChargesController#paypal_payment as HTML Parameters:
{"tx"=>"8R95473028301340P", "st"=>"Completed", "amt"=>"20.00",
"cc"=>"USD", "cm"=>"", "item_number"=>""}
Filter chain halted as :auth_request rendered or redirected
Completed 200 OK in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms)

Related

Frequent unexpected requests logged by Rails app in EC2 - from Amazon public IP addresses - Why?

I'm running a rails app that writes files to Amazon S3. Now I have uniqorn running as server and see all lots of request coming in from different amazon AWS IP-addresses.
Here is a part of my log file:
Started GET "/" for 54.245.168.11 at 2016-10-02 18:30:50 +0000
Processing by StaticPagesController#home as */*
Rendered static_pages/home.html.erb within layouts/application (0.2ms)
Rendered layouts/_shim.html.erb (0.1ms)
Rendered layouts/_header.html.erb (0.3ms)
Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
Started GET "/" for 54.252.254.235 at 2016-10-02 18:30:51 +0000
Processing by StaticPagesController#home as */*
Rendered static_pages/home.html.erb within layouts/application (0.2ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_header.html.erb (0.3ms)
Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
Started GET "/" for 54.232.40.107 at 2016-10-02 18:30:52 +0000
Processing by StaticPagesController#home as */*
Rendered static_pages/home.html.erb within layouts/application (0.7ms)
Rendered layouts/_shim.html.erb (0.2ms)
Rendered layouts/_header.html.erb (1.8ms)
Completed 200 OK in 12ms (Views: 10.6ms | ActiveRecord: 0.0ms)
Started GET "/" for 54.252.79.139 at 2016-10-02 18:30:52 +0000
Processing by StaticPagesController#home as */*
Rendered static_pages/home.html.erb within layouts/application (0.7ms)
Rendered layouts/_shim.html.erb (0.3ms)
Rendered layouts/_header.html.erb (1.5ms)
Completed 200 OK in 13ms (Views: 11.6ms | ActiveRecord: 0.0ms)
Started GET "/" for 54.250.253.203 at 2016-10-02 18:30:52 +0000
Processing by StaticPagesController#home as */*
Rendered static_pages/home.html.erb within layouts/application (0.5ms)
Rendered layouts/_shim.html.erb (0.1ms)
Rendered layouts/_header.html.erb (0.3ms)
Completed 200 OK in 4ms (Views: 3.2ms | ActiveRecord: 0.0ms)
Started GET "/" for 54.243.31.203 at 2016-10-02 18:30:54 +0000
Processing by StaticPagesController#home as */*
Rendered static_pages/home.html.erb within layouts/application (0.5ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_header.html.erb (0.3ms)
Completed 200 OK in 4ms (Views: 3.5ms | ActiveRecord: 0.0ms)
I can't find any info on this online. My application isn't live yet, so nobody looks at it. Why is AWS doing this?
These are Route 53 Health Checks, which are a different type of health check than the health checks configured in Elastic Load Balancer (ELB), and different from the EC2 instance health and reachability checks that EC2 automatically performs on every EC2 instance.
Take a look at the published AWS IP Address Ranges, and you'll find that these match up to the address blocks specifically assigned to Route 53 Health Checks, quite nicely.
For example, this request...
Started GET "/" for 54.232.40.107 at 2016-10-02 18:30:52 +0000
...matches this entry...
{
"ip_prefix": "54.232.40.64/26",
"region": "sa-east-1",
"service": "ROUTE53_HEALTHCHECKS"
},
...because 54.232.40.64/26 is the CIDR spec for the IP address block from 54.232.40.64 through 54.232.40.127.
If you configured a Route 53 health check against your stack, then you probably have your answer, at this point.
Route 53 Health Checks are often used to drive the logic of complex DNS configurations, such as in cases where there are multiple candidate servers geographically distributed, and you want to control the answer returned by DNS based on the health of the servers... but they can also be used for monitoring latency and application performance (measuring TCP connect time and time-to-first-byte, as well as availability), tied into CloudWatch alarms, and used to drive scaling and other logic. If you configured anything like this, the question may be solved.
But if you didn't, this could be a case of another AWS user who has configured health checks against an IP address they were formerly using, or has configured the checks against your IP address or hostname by simple mistake.
If that is the case, you'll need to inspect the request headers from the incoming request. You'll find something like this:
User-Agent: Amazon Route 53 Health Check Service; ref:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; report http://amzn.to/zzzzzzz
With these values in hand, along with the other headers and any relevant log entries, you can visit the "report" URL provided in the headers you captured, (it's similar to the one I've shown above, captured from my logs, but sanitized since it seems to be generic, but I'm not certain -- the link in my logs redirects me here) and submit a request for AWS to work with you to to eliminate the unwanted health checks.
But first, try this...
Take the value immediately after "ref:" and create a URL from it, using this template:
https://console.aws.amazon.com/route53/healthchecks/home#/details/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
(Replace xxxx with your ref:, excluding the actual string ref:).
If the health check is from your own AWS account, and you're logged into the console, and have permission to view it, then this crafted link should bring the health check right up for you to view. If you get an error that you are "not authorized to access this resource," then the health check is not from your AWS account, or you aren't a privileged user on the AWS account and thus may lack the ability to view it.

Passenger stop to write log

Started GET "/home" for 117.55.68.xxx at 2012-11-05 22:56:06 +0900
Processing by PageController#home as HTML
Parameters: {"id"=>"420"}
Started POST "/login" for 61.211.5.107 at 2012-11-05 23:25:52 +0900
Processing by UsersController#login as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxxxxxx=", "username"=>"***DELETED***", "password"=>"***DELETED***", "commit"=>"login"}
Rendered users/login.html.haml within layouts/application (6.7ms)
Completed 200 OK in 142ms (Views: 103.5ms | ActiveRecord: 0.0ms)
I am using passenger 3.0.11.
I have encountered the problem that the log is not written.
It's happen when the "Completed" is not output.
After "Completed" is not output, log is not written for 20-40 minutes.
Does anyone have idea?
This usually happens when you have a memory issue. Ruby cannot write to log because it has run out of memory.

What is the difference in "Processing by Contoller#method as */*" and "Processing by BillsController#show as HTML"

All of my rails 3.2.2 ActiveRecord methods are being executed twice. I noticed that each execution is being processed differently, see the examples I grabbed from the console below...
Started GET "/api/bills/Jeremy%20Fox" for 127.0.0.1 at 2012-03-20 23:16:43 -0400
Processing by BillsController#show as HTML
Parameters: {"username"=>"Jeremy Fox"}
BillsForUsers Load (2.4ms) SELECT "bills_for_users".* FROM "bills_for_users" WHERE "bills_for_users"."billusername" = 'Jeremy Fox'
Completed 200 OK in 47ms (Views: 11.2ms | ActiveRecord: 2.4ms)
Started GET "/api/bills/Jeremy%20Fox" for 127.0.0.1 at 2012-03-20 23:16:44 -0400
Processing by BillsController#show as */*
Parameters: {"username"=>"Jeremy Fox"}
BillsForUsers Load (1.1ms) SELECT "bills_for_users".* FROM "bills_for_users" WHERE "bills_for_users"."billusername" = 'Jeremy Fox'
Completed 200 OK in 33ms (Views: 28.1ms | ActiveRecord: 1.1ms)
Can anyone explain to me why all of my ActiveRecord methods are being executed twice and/or what the difference is between Processing by BillsController#show as HTML and Processing by BillsController#show as */*?
Thanks.
It turns out the problem was actually the JSONView Chrome extension. As it states in the options menu...
Use safe method to parse HTTP response (*)
(*) : safe method forces the browser to send an extra HTTP request to get the raw HTTP content.
After spending days trying to figure out what I was doing wrong in my code, it was actually just chrome!
Hope no one else runs into this stupid issue.
-Jeremy
I've been grappling with this same issue. The HTML Validator Chrome extension is also guilty (with none of the fine print.)
In my case, I'm calling a ModestModel-backed search request, so the first hit (and rendering) was succeeding, followed by a phantom 500 as my non-DB search model was out of scope and nil on the second request.
Thanks, Jeremy!

406 error when template and partial exist as well as when they don't exist

I'm getting a 406 error and it's rendering a blank white page, even though the log makes it look like it's rendering my shared/404 page. I can even remove the layout and 404 page and same error. Any ideas?
Started GET "/" for 127.0.0.1 at 2012-02-19 22:26:56 -0800
Processing by MinisitesController#show as HTML
Account Load (0.4ms) SELECT "accounts".* FROM "accounts" WHERE "accounts"."full_domain" = 'test.eg.local' AND (accounts.deleted_at IS NULL) LIMIT 1
Rendered shared/404.html.haml (0.3ms)
Completed 406 Not Acceptable in 81ms (Views: 12.3ms | ActiveRecord: 2.2ms)

ActiveResource adding about 1 second of overhead?

I have two simple Ruby on Rails applications with one using ActiveResource to access the other. The ActiveResource processing seems to be adding ~1000ms of overhead. These are the trace logs:
Requester:
Started GET "/documents/1/retrieve?name=LRActionItems" for 127.0.0.1 at 2011-07-28 17:24:07 -0400
Processing by DocumentsController#retrieve as
Parameters: {"name"=>"LRActionItems", "id"=>"1"}
retrieving persistent_data for id 1 - name LRActionItems
GET http://localhost:3333/field_value_collections/1/field_values/find_by_field_name.xml?field_name=LRActionItems
--> 200 OK 639 (1030.1ms)
Rendered text template (0.0ms)
Completed 200 OK in 1037ms (Views: 1.0ms | ActiveRecord: 1.0ms)
Responder:
Started GET "/field_value_collections/1/field_values/find_by_field_name.xml?field_name=LRActionItems" for 127.0.0.1 at 2011-07-28 17:24:08 -0400
Processing by FieldValuesController#find_by_field_name as XML
Parameters: {"field_name"=>"LRActionItems", "field_value_collection_id"=>"1"}
Completed 200 OK in 3ms (Views: 1.0ms | ActiveRecord: 0.0ms)
cache: [GET /field_value_collections/1/field_values/find_by_field_name.xml?field_name=ULActionItems] miss
As you can see, the responder is responding in 3ms but the requester is requiring 1037ms because the ActiveResource request requires 1030.1ms.
I am in production mode (development mode is actually just a little slower - 10-15ms)
I'm using WEBrick and have done very little customization from the projects as generated.
Is this normal performance? Is there any configuration that can make this much better?

Resources