Config issue in Private_pub and rainbows configuration - ruby-on-rails-3

I have configured private_pub with rainbows like this
rainbows.conf:
Rainbows! do
end
private_pub.ru:
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"
require "faye/redis"
Faye::WebSocket.load_adapter('rainbows')
yml = YAML::load_file("config/private_pub_redis.yml")[ENV["RAILS_ENV"] || "development"]
PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
run PrivatePub.faye_app(:timeout => 1, :engine => {
:type => Faye::Redis,
:host => yml["server"],
:port => yml["port"]
})
I run the server using this:
rainbows private_pub.ru -c config/rainbows.conf -E production -p 9292
Now every time the page loads with subscription i get this error and the subscription fails:
Server error log when the page is loaded on the browser:
E, [2013-06-03T22:29:10.673828 #17953] ERROR -- : app error: undefined method call' for nil:NilClass (NoMethodError)
E, [2013-06-03T22:29:10.674195 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-websocket-0.4.7/lib/faye/websocket.rb:143:ininitialize'
E, [2013-06-03T22:29:10.674343 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-0.8.9/lib/faye/adapters/rack_adapter.rb:131:in new'
E, [2013-06-03T22:29:10.674465 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-0.8.9/lib/faye/adapters/rack_adapter.rb:131:inhandle_websocket'
E, [2013-06-03T22:29:10.674563 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-0.8.9/lib/faye/adapters/rack_adapter.rb:88:in call'
E, [2013-06-03T22:29:10.674642 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/max_body.rb:66:inblock in call'
E, [2013-06-03T22:29:10.674717 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/max_body.rb:59:in catch'
E, [2013-06-03T22:29:10.674790 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/max_body.rb:59:incall'
E, [2013-06-03T22:29:10.674863 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/process_client.rb:44:in process_loop'
E, [2013-06-03T22:29:10.674937 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/base.rb:32:inprocess_client'
E, [2013-06-03T22:29:10.675015 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:632:in worker_loop'
E, [2013-06-03T22:29:10.675099 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/http_server.rb:45:inworker_loop'
E, [2013-06-03T22:29:10.675172 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in spawn_missing_workers'
E, [2013-06-03T22:29:10.675243 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/http_server.rb:61:inspawn_missing_workers'
E, [2013-06-03T22:29:10.675315 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:142:in start'
E, [2013-06-03T22:29:10.675387 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/bin/rainbows:127:in'
E, [2013-06-03T22:29:10.675458 #17953] ERROR -- : /usr/local/bin/rainbows:23:in load'
E, [2013-06-03T22:29:10.675529 #17953] ERROR -- : /usr/local/bin/rainbows:23:in'
Browser console error log on :
GET http://localhost:9292/faye?message=%5B%7B%22channel%22%3A%22%2Fmeta%2Fhands…3A%5B%22callback-polling%22%5D%2C%22id%22%3A%221%22%7D%5D&jsonp=__jsonp1__ 400 (Bad Request) faye.js:1
WebSocket connection to 'ws://localhost:9292/faye' failed: Unexpected response code: 500 http://localhost:8080/
WebSocket connection to 'ws://localhost:9292/faye' failed: WebSocket is closed before the connection is established.

For anyone facing the same issue answers are here: https://groups.google.com/forum/#!topic/faye-users/oQ5JCoV7qh8
The issue here was that i was using older version of faye-websocket.
Another issue was that I was using rainbows 4.5 while faye[0.8] supported older rainbows

Related

Getting error trying to run script with SQLTools

I tryed to use the SqlTools extansion for VSCorde and wanted to run the script with it and gives me this erros (I'm using github codespaces)
[1674681282366] INFO (ext): EXECUTING COMMAND => sqltools.getConnections
[1674681282367] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest
[1674681282368] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest
[1674681282369] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest
[1674681284190] INFO (ext): EXECUTING COMMAND => sqltools.getConnections
[1674681284191] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest
[1674681284191] INFO (ls): REQUEST RECEIVED => connection/ConnectRequest
[1674681284192] INFO (ls): Connection instance created for panel.
ns: "conn-manager"
[1674681284193] ERROR (ls): {"code":-1,"data":{"driver":"MySQL","driverOptions":{"mysqlOptions":{"authProtocol":"default"}}},"name":"Error"}
ns: "conn"
[1674681284193] ERROR (ls): Connecting error: {"code":-1,"data":{"driver":"MySQL","driverOptions":{"mysqlOptions":{"authProtocol":"default"}}},"name":"Error"}
ns: "conn-manager"
[1674681284193] ERROR (ls): Open connection error
ns: "conn-manager"
[1674681284194] ERROR (ext): ERROR: Error fetching records. connect ECONNREFUSED 127.0.0.1:3306, {"code":-1,"data":{"driver":"MySQL","driverOptions":{"mysqlOptions":{"authProtocol":"default"}}}}
ns: "error-handler"```

Mailer function Ruby on Rails issue

I am trying compile a function with user id, but not working out. Tried different ways but getting nil as response in my production logs.
Any help is welcome
def function(user)
attachments['example.pdf'] = File.read("public/#{#user.id}_file.pdf")
#user = user
mail :subject => 'example', to: user.email, from: 'invoice#domain.com', track_opens: true
end
Log:
D, [2019-07-08T10:51:56.838759 #64733] DEBUG -- :
TestMailer#send_sub_month: processed outbound mail in 1.1ms I,
[2019-07-08T10:51:56.839003 #64733] INFO -- : Completed 500 Internal
Server Error in 5ms (ActiveRecord: 0.4ms) F,
[2019-07-08T10:51:56.839615 #64733] FATAL -- : F,
[2019-07-08T10:51:56.839671 #64733] FATAL -- : NoMethodError
(undefined method 'id' for nil:NilClass): F,
[2019-07-08T10:51:56.839710 #64733] FATAL -- : F,
[2019-07-08T10:51:56.839750 #64733] FATAL -- :
app/mailers/test_mailer.rb:90:in `send_sub_month'
The logs say that you are trying to access the id attribute of an empty object.
NoMethodError (undefined method id' for nil:NilClass)
You have a string where the user is used is higher than the string where the user is defined
Try this:
def function(user)
#user = user
attachments['example.pdf'] = File.read("public/#{#user.id}_file.pdf")
mail :subject => 'example', to: user.email, from: 'invoice#domain.com', track_opens: true
end
Updated.
If you pass a user as an argument to a function, then it makes no sense to create a variable for it.
def function(user)
attachments['example.pdf'] = File.read("public/#{user.id}_file.pdf")
mail :subject => 'example', to: user.email, from: 'invoice#domain.com', track_opens: true
end

ExAws not working on production release (Phoenix/Arc/ExAws)

I've been trying to create an uploader for avatars, but I've been facing some issues, the code works perfectly on dev, but on the production release, I get this error:
=SUPERVISOR REPORT==== 8-Jul-2016::22:35:41 ===
Supervisor: {local,'Elixir.ExAws.Supervisor'}
Context: child_terminated
Reason: {#{'__exception__' => true,
'__struct__' => 'Elixir.Poison.SyntaxError',
message => <<"Unexpected token: <">>,
token => <<"<">>},
[{'Elixir.Poison.Parser','parse!',2,
[{file,"lib/poison/parser.ex"},{line,56}]},
{'Elixir.Poison','decode!',2,
[{file,"lib/poison.ex"},{line,83}]},
{'Elixir.ExAws.InstanceMeta',security_credentials,1,
[{file,"lib/ex_aws/instance_meta.ex"},{line,16}]},
{'Elixir.ExAws.Config.AuthCache',refresh_config,2,
[{file,"lib/ex_aws/config/auth_cache.ex"},{line,37}]},
{'Elixir.ExAws.Config.AuthCache',handle_call,3,
[{file,"lib/ex_aws/config/auth_cache.ex"},{line,27}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,615}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,647}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]}
Offender: [{pid,<0.2009.0>},
{id,'Elixir.ExAws.Config.AuthCache'},
{mfargs,
{'Elixir.ExAws.Config.AuthCache',start_link,
[[{name,'Elixir.ExAws.Config.AuthCache'}]]}},
{restart_type,permanent},
{shutdown,5000},
{child_type,worker}]
22:35:41.624 [error] Ranch protocol #PID<0.2011.0> (:cowboy_protocol) of listener MyApp.Endpoint.HTTP terminated
** (exit) exited in: GenServer.call(ExAws.Config.AuthCache, {:refresh_config, %ExAws.S3{config: %{access_key_id: [{:system, "AWS_ACCESS_KEY_ID"}, :instance_role], host: %{"ap-northeast-1" =>
"s3-ap-northeast-1.amazonaws.com", "ap-southeast-1" => "s3-ap-southeast-1.amazonaws.com", "ap-southeast-2" => "s3-ap-southeast-2.amazonaws.com", "eu-central-1" => "s3-eu-central-1.amazonaws.c
om", "eu-west-1" => "s3-eu-west-1.amazonaws.com", "sa-east-1" => "s3-sa-east-1.amazonaws.com", "us-east-1" => "s3.amazonaws.com", "us-west-1" => "s3-us-west-1.amazonaws.com", "us-west-2" => "
s3-us-west-2.amazonaws.com"}, http_client: ExAws.Request.HTTPoison, json_codec: Poison, region: "us-east-1", scheme: "https://", secret_access_key: [{:system, "AWS_SECRET_ACCESS_KEY"}, :insta
nce_role]}, service: :s3}}, 5000)
** (EXIT) an exception was raised:
** (Poison.SyntaxError) Unexpected token: <
(poison) lib/poison/parser.ex:56: Poison.Parser.parse!/2
(poison) lib/poison.ex:83: Poison.decode!/2
(ex_aws) lib/ex_aws/instance_meta.ex:16: ExAws.InstanceMeta.security_credentials/1
(ex_aws) lib/ex_aws/config/auth_cache.ex:37: ExAws.Config.AuthCache.refresh_config/2
(ex_aws) lib/ex_aws/config/auth_cache.ex:27: ExAws.Config.AuthCache.handle_call/3
(stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:647: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Thanks.
Your stack trace says that Poison, a dep that ExAws uses, failed to decode a json. If you check the module that made that call (lib/ex_aws/instance_meta.ex, you can read it here), you'll find that it communicates with Amazon to check your credentials.
The most probable thing is that your configuration is incorrect and Amazon is sending you an error message formatted as an XML or HTML (both begin with <).
ExAws config depends on env vars, so that's also probably why it works on dev, but not on production.

Jmeter http post sampler syntax

I'm triyng to test a rest api using jmeter script. When I launch the test, I get the following exception:
{"timestamp" : 1463775753585,
"status" : 400,
"error" : "Bad Request",
"exception" : "org.springframework.http.converter.HttpMessageNotReadableException",
"message" : "Could not read JSON: (was java.lang.NullPointerException) (through reference chain: com.tutos.example.models.Product[\"category\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: com.tutos.example.models.Product[\"category\"])",
"path" : "/product"
}
Here is my data of post:
{"code":${productCode}, "intitule":"${productName}", "cost":"${cost}", "category":{"id":"${categoryId}"}}
But when I remove the property category, everything is OK.
What am I missing please ?

Query regarding the failure of frisby test cases results

While running the code with necessary validations, the test cases are not executed. It throws the following error message.
1) Frisby Test: Test case for single post
Message:
Expected 500 to equal 201.
Stacktrace:
Error: Expected 500 to equal 201.
at null.<anonymous> (/home/admin/wrkspc/api-tests/node_modules/frisby/lib/frisby.js:462:42)
at null.<anonymous> (/home/admin/wrkspc/api-tests/node_modules/frisby/lib/frisby.js:1043:43)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
2) Frisby Test: Test case for single post
Message:
Error: Error parsing JSON string: Unexpected '<'
Given: <html><head><title>Apache Tomcat/7.0.53 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.53</h3></body></html>
Stacktrace:
Error: Error parsing JSON string: Unexpected '<'
Given: <html><head><title>Apache Tomcat/7.0.53 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.53</h3></body></html>
at _jsonParse (/home/admin/wrkspc/api-tests/node_modules/frisby/lib/frisby.js:1174:11)
at Frisby.<anonymous> (/home/admin/wrkspc/api-tests/node_modules/frisby/lib/frisby.js:919:20)
at null.<anonymous> (/home/admin/wrkspc/api-tests/node_modules/frisby/lib/frisby.js:1081:18)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Error: Expected 500 to equal 201.
Means that what you are testing is throwing an error.
Error parsing JSON string: Unexpected '<'
Just means that the response you received was not in proper JSON format. In this case, it seems to be html. This second error is expected your system under test is throwing an error message in the format it is comfortable with, html, and not in JSON.
The real error:
The server encountered an internal error that prevented it from fulfilling this request.
You can use the inspectBody() to you see return of the test.
More informations: http://frisbyjs.com/docs/api/#inspectBody()