Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to the hook handler. Is the handler running? #3

Closed
icambridge opened this issue Sep 10, 2015 · 6 comments
Closed

Error connecting to the hook handler. Is the handler running? #3

icambridge opened this issue Sep 10, 2015 · 6 comments

Comments

@icambridge
Copy link
Contributor

I get the following on travis.

$ node_modules/dredd/bin/dredd
Configuration dredd.yml found, ignoring other arguments.
Starting server with command: app/api_v6/console server:run --docroot=web 127.0.0.1:8081
Waiting 3 seconds for server command to start...
info: Beginning Dredd testing...
Spawning `bin/dredd-hooks-php` hooks handler
Error connecting to the hook handler. Is the handler running?
{ [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }

I have no idea why, I've ensured that the file is there and executable. So I've ran the script by itself and put it into the background. This just resulted in getting socket errors when the other tests were running.

@ddelnano
Copy link
Owner

When you say "running on travis" do you mean your project that is using dredd to test your web service or are you talking about my repository running on travis?

Please post your travis.yml if its your project. I think I can tell what the issue is from that output but I just want to verify.

Edit: Added information

@icambridge
Copy link
Contributor Author

My project running on travis using dredd.

language: php
php:
  - 5.5
env:
    global:
         - ELASTICSEARCH_VERSION="1.7.1"
         - ELASTICSEARCH_EXTENSION_VERSION="3.0.0"
         - FRONTEND_PUBLIC_DIR=$TRAVIS_BUILD_DIR/src/Foodpanda/Bundle/Shop/SiteBundle/Resources/public
         - COUNTRY_CODE=va
         - PLATFORM=foodpanda

before_install:
    # php redis config
    - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

    # symfony config
    - cd $TRAVIS_BUILD_DIR && rm -Rf app/core/config/countries_parameters/*
    - cd $TRAVIS_BUILD_DIR && cp app/core/config/parameters_test.yml app/core/config/countries_parameters/foodpanda_va.yml

    # elastic search
    - wget --no-check-certificate https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.deb
    - sudo dpkg -i --force-confnew elasticsearch-$ELASTICSEARCH_VERSION.deb
    - rm elasticsearch-$ELASTICSEARCH_VERSION.deb

    # elasticsearch plugin
    - sudo /usr/share/elasticsearch/bin/plugin -v --url http://repo.foodpanda.com/foodpanda-extension-$ELASTICSEARCH_EXTENSION_VERSION.jar --install foodpanda-extension
    - sudo service elasticsearch start

    # MySQL 5.6
    - sudo apt-get remove --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5
    - sudo apt-get autoremove
    - sudo apt-get autoclean
    - sudo apt-add-repository ppa:ondrej/mysql-5.6 -y
    - sudo apt-get update
    - sudo apt-get install mysql-server-5.6 mysql-client-5.6
    - mysql -uroot -e "SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION"

install:
  - 'cd $TRAVIS_BUILD_DIR && composer self-update'
  - 'cd $TRAVIS_BUILD_DIR && composer install --no-interaction --optimize-autoloader'
  - 'cd $TRAVIS_BUILD_DIR && rm -Rf app/core/cache/*'
  - 'cd $TRAVIS_BUILD_DIR && rm -Rf app/core/logs/*'
  - 'cd $TRAVIS_BUILD_DIR && chmod -R 777 app'
  - 'cd $TRAVIS_BUILD_DIR && chmod -R 777 bin/dredd-hooks-php'
  - 'cd $TRAVIS_BUILD_DIR && php app/console assets:install web --env=test'
script:
  - AUTO_DROP_DB=1 bin/phpunit -c app/api
  - AUTO_DROP_DB=1 bin/phpunit -c app/core
  - AUTO_DROP_DB=1 bin/phpunit -c app/shop
  - AUTO_DROP_DB=1 bin/phpunit -c app/internal
  - bin/behat -p cart --suite=cart_suite --format progress -n --strict
  - AUTO_DROP_DB=1 bin/behat --profile=integration --suite=integrationApi --format progress -n --strict
  - bin/phpspec run
  - AUTO_DROP_DB=1 bin/behat --profile=api_v6 --format progress -n --strict
  - node_modules/dredd/bin/dredd
cache:
  apt: true
  directories:
    - $HOME/.composer
#    - node_modules
services:
  - redis-server
before_deploy:
  - $TRAVIS_BUILD_DIR/build-tools/create-artifact-archive -o $TRAVIS_BUILD_DIR/build-tools/build.tar.gz -b $TRAVIS_BRANCH -c $TRAVIS_COMMIT
deploy:
  provider: releases
  api-key: 9
  file: $TRAVIS_BUILD_DIR/build-tools/build.tar.gz
  skip_cleanup: true
  on:
    tags: true
    all_branches: true

and dredd.yml

dry-run: null
hookfiles: 'hooks/hooks.global.php'
language: 'bin/dredd-hooks-php'
sandbox: false
server: 'app/api_v6/console server:run --docroot=web 127.0.0.1:8081'
server-wait: 3
init: false
custom: {}
names: false
only: []
reporter: cli
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
color: true
level: info
timestamp: false
silent: false
path: []
blueprint: apiary.apib
endpoint: 'http://127.0.0.1:8081/app_dev_api_v6.php/'

@ddelnano
Copy link
Owner

Can you try to run dredd without using the dredd.yml?? Only reason I ask is because on the Dredd website it specifically says
Dredd.yml unstable feature

Read the docs where I got the picture here. Maybe @netmilk can comment on your dredd.yml file. Does this work locally? When I run dredd I use the following command since I figured it would be a bad idea to use the dredd.yml.

dredd ./laravel.apib http://localhost:8001 --server "php -S 0.0.0.0:8001 -t public/" --language vendor/bin/dredd-hooks-php --hookfiles tests/dredd/hooks/hookfile.php

@icambridge
Copy link
Contributor Author

This appears to be an issue with dredd. I added - bin/dredd-hooks-php & to the script: section instead of before script section and dredd now runs.

It fails for another reason, connecting to the app/server

@netmilk
Copy link

netmilk commented Sep 11, 2015

Hey @icambridge, @ddelnano,

dredd.yml is no longer an unstable feature and is widely used. I'll fix the documentation according to reality. :)

Ad your issue, @icambridge: Dredd is waiting 1 second after spawning the hook worker to connect to it. In this case I would suspect something in your hook files is taking longer time than this 1 second. Is it possible? This interval is unfortunately not configurable at this moment. I added it to the requirements for refactoring of worker client in Dredd here: apiaryio/dredd#235

@netmilk
Copy link

netmilk commented Sep 11, 2015

@icambridge Is you project open-source or would you be willing to share the code of the project with me? I'm super interested to know more how you use hooks and Dredd and to know more how do you organise code in hooks and what roadblocks did you hit while using Dredd. It would be super useful to know more. Please, feel free to reach out to me via twitter @ntmlk, skype netmilk or email adam@apiary.io. Looking forward to hear from you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants