How to make cucumber/selenium run Thin server instead of Webrick - selenium

where do I have to setup or configure to fire cucumber/selenium test to run Thin server instead of the default Webrick server?

To explicitly setup Thin, create a file within the features/support directory with the following:
Capybara.server do |app, port|
require 'rack/handler/thin'
Rack::Handler::Thin.run(app, :Port => port)
end

Related

Rails App on AWS Elasticbeanstalk mail send fails with ESMTP No Relay Access Allowed From IP

I have a rails app that I have deployed to AWS Elastic Beanstalk. The app uses devise to handle user authentication, and its set to be able to invite users.
My issue is that when I try to invite a user, I get the following error:
Net::SMTPFatalError (554 secureserver.net ESMTP No Relay Access Allowed From <my_eb_assigned_ip>
(I am hosting the domain on GoDaddy).
In development, the mailer functionality works fine; my smtp settings are set to (common to all environments):
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtpout.secureserver.net",
:port => 80,
:domain => "www.my_domain.com",
:authentication => :plain,
:user_name => "do-not-reply#my_domain.com",
:password => my_pass,
}
And in my production.rb config file:
config.action_mailer.default_url_options = { :host => 'aws_sb.elasticbeanstalk.com' }
Is there another setting I have to enable in Elasticbeanstalk to allow relay access? Or am I missing a production specific setting from my rails configuration?
I figured out it was the port value that I was setting....when I switched the port to 25, it works in production. However, for development, port 25 wasn't working; it would only work in dev when the port was 80.
So I ended up moving the entire smtp mailer settings into the environment specific settings (from the config/environment.rb file), and setting the production port to 25, and the development port to 80, and that appeared to make both environments work.
Edit: After another push, I was seeing the same issue, and none of the ports I tried were resolving the issue. So I ended up switching all my mail functionality to be sent through Amazon SES, and that appears to be functioning great so far.

PHPStorm unable to make external connection with xdebug

My OS is Mac Mountain lion.
My PhpStorm version is 5.0.4.
Here is my php xdebug info:
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => 127.0.0.1 => 127.0.0.1
xdebug.remote_log => data/logs/xdebug.log => data/logs/xdebug.log
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.idekey => no value => no value
I can debug PhpScript Run Type in PhpStorm,It works fine.So I think xdebug configure well.
But after I try follow the "Zero Configure Debug"(Which with Webapplication Run Type),Phpstorm can not connect with the incoming connection.
Here is my step:
Click Start Listion Php Connection.(Toggle the call to green)
Click Run->Break at first line in PhpScript,and set breakpoint at first statement.
Choose My WebApplication Config and click Debug button.Then it launches chrome and link to my phpscript.(with ?XDEBUG_SESSION_START=19869)
In PhpStorm,Debugger shows Waiting for incoming connection with ide key '19869'.
In termial,printlsof -i4TCP:9000.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
webide 288 wangfeng 69u IPv6 0xa83881cdce30c579 0t0 TCP *:cslistener (LISTEN)
Open Chrome's Developer Tool,Select Cookies.
XDEBUG_SESSION 19869 localhost / Wed, 30 Jan 2013 05:27:17 GMT 19
Refresh Chrome.Not able connect with PhpStorm debug connection.
Additional:
My firewall was closed.
My Server is nginx.My phpwebapp and server is all at my local machine.
Does it cause ipv6?
Hopes help!I have try everything,extensions bookmarklets,not work at all.
It's possible that port 9000 is being used by some other process.
In php.ini set xdebug.remote_port=9001 or another unused port of your choosing.
In PHPStorm go to Settings->PHP->Debug and under the Xdebug section set Debug port to 9001.
Restart your web server.
Start debugging.
After checking all the configuration in php.ini file and the IDE, do not forget to add the browser-specific extension that basically communicates via the IDE via IDE Key.
Please refer to this link

Working locally, can't connect in Laravel to remote DB

I'm trying to work locally in Laravel and am having trouble connecting to a remote database. I've used my domain name (domain.org) as my host, and then password, username and database name as normal. But I get this error:
PDO::__construct(): Premature end of data (mysqlnd_wireprotocol.c:553)
If I look at the file where the error is happening, it's in my PDO connection in the MySQL driver. I asked my ISP about settings and he said to use domain.org or the IP. I tried both and I still get the error. I tried setting the port to the standard 3306 and still get the error. I can't use localhost as my host because that would refer to my local computer. Can someone help? What do I need to do to connect?
I think this is a difference between the encryption used in the version of MySQL on your web host, and that used by your PHP version.
Have a look at the accepted answer on this question:
Remote mySQL connection throws "cannot connect to MySQL 4.1+ using the old insecure authentication" error from XAMPP
As regards a solution, your web host may or may not be willing to change your MySQL settings - but my guess is that if they are running an old MySQL, they will also be running an old version of PHP. Laravel requires 5.3.
To use "Remote Mysql" you would need to add your IP to the white-list on the server and also configure Mysql to accept remote connections
Old question but, a lot people may need this, so adding what worked for me
In 5.6+, also will be working on lessor version
DB_CONNECTION_REMOTE=mysql
DB_HOST_REMOTE=remotehost
DB_PORT_REMOTE=3306
DB_DATABASE_REMOTE=database_name
DB_USERNAME_REMOTE=database_user
DB_PASSWORD_REMOTE=database_password
and in config/database.php
'connections' => [
'mysqlRemote' => [
'driver' => 'mysql',
'host' => env('DB_HOST_REMOTE', '127.0.0.1'),
'port' => env('DB_PORT_REMOTE', '3306'),
'database' => env('DB_DATABASE_REMOTE', 'forge'),
'username' => env('DB_USERNAME_REMOTE', 'forge'),
'password' => env('DB_PASSWORD_REMOTE', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
and then in your controller
$records = DB::connection('mysqlRemote')->select( DB::raw('SELECT `col1`, `col2` FROM `table`') );
if your IP is white-listed, it should work fine, tested in Laravel 5.6

Is it possible to start resque-web listening to a redis socket?

I have disabled redis listening to port 6379 and enabled the websocket. It works wonderfully from my application, but when I launch resque-web it keeps listening trough network interface and fails with message:
Can't connect to Redis! (redis://127.0.0.1:6379/0)
Someone knows if it's possible to make resque-web use the socket instead of the network?
Thanks in advance
I've been reading resque-web's code and I realized that it internally loads any path you provide as parameter to the command. So I have created a plain ruby script that connects to Redis with redis gem and then assigns this instance to Resque.redis:
Just created a file called 'resque-web-hack.rb':
require 'redis'
require 'resque'
$redis = Redis.new(:path => '/tmp/redis.sock')
Resque.redis = $redis
And then used it like this:
$ resque-web /path/to/my/file/resque-web-hack.rb
It's just a hack, but it works for me by now...
I just fixed same problem :) So here is the solution
In my ./config/resque.yml I have this line
development: /tmp/redis.sock
This is my RAILS_ROOT/config/initializers/resque.rb
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
if resque_config[rails_env] =~ /^\// # using unix socket
Resque.redis = Redis.new(:path => resque_config[rails_env])
else
Resque.redis = resque_config[rails_env]
end

using apn_sender on heroku

We built an api in rails and are hosting it on heroku and using apn_sender to do the push notifications. We got everything running locally with apn_sender but when we push it to heroku and run
heroku rake apn:sender
we get the following error "Connection refused - Unable to connect to Redis on 127.0.0.1:6379"
We added the redistogo addon.
UPDATE
We added a resque.rb initializer:
require 'resque'
uri = URI.parse(ENV["REDISTOGO_URL"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
and called to start up the worker
heroku rake environment apn:sender
and everything seemed to work.
Ok, so after further testing, the update I put in above doesn't work for very long before it crashes. We then followed this http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/
Changing
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
end
to
task "apn:setup" => :environment do
ENV['QUEUE'] = '*'
end
and
desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"
to
desc "Alias for apn:work (To run workers on Heroku)"
task "jobs:work" => "apn:work"
and it worked like a charm. Also note, that we had to add a worker dyno in heroku, which costs .05/hour or $35/month.