Timeout Facebook Login with hwioauth bundle : Timeout Gateway 504

323 Views Asked by At

Hi!

I am becoming mad with the following error, found into the prod log, with Facebook Login, by HWIOAuthBundle. I have never encountered this bug on our localhosts. It occurred (and continues to occur) several times on prod, sporadically. I tried to set verify_peer to false inside config.yml, put off ipv6 on the nginx server, etc. Nothing had solved this problem.

Here is the exact error :

[2017-09-05 17:48:16] request.CRITICAL: Uncaught PHP Exception
HWI\Bundle\OAuthBundle\OAuth\Exception\HttpTransportException: 
"Error while sending HTTP request" at 
/home/keywinf/htdocs/www/vendor/hwi/oauth-bundle/OAuth/ResourceOwner/AbstractResourceOwner.php line 255 
{"exception":"[object] (HWI\\Bundle\\OAuthBundle\\OAuth\\Exception\\HttpTransportException(code: 28): 
Error while sending HTTP request at /home/keywinf/htdocs/www/vendor/hwi/oauth-bundle/OAuth/ResourceOwner/AbstractResourceOwner.php:255, Buzz\\Exception\\RequestException(code: 28): 
Connection timed out after 60000 milliseconds at /home/keywinf/htdocs/www/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php:29)"} []

config.yml

hwi_oauth:
    firewall_names: [main]

    use_referer: true

    fosub:
        username_iterations: 30
        properties:
            facebook: facebookId
        resource_owners:
            facebook:
                type:                facebook
                client_id:           "%facebook_id%"
                client_secret:       "%facebook_secret%"
                infos_url:     'https://graph.facebook.com/me?fields=id,name,first_name,last_name,picture.type(large),email,gender,birthday,location,age_range'
                scope: "email,user_friends"
            http_client:
                timeout: 60

security.yml

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    api:
        pattern: ^/api/[a-z0-9](-[a-z0-9])+/
        stateless: true
        simple_preauth:
            authenticator: api_key_authenticator
        provider: api
    main:
        pattern:      ^/
        anonymous:    true
        provider:     main
        switch_user: true
        form_login:
            login_path: fos_user_security_login
            check_path: fos_user_security_check
            success_handler: acme.security.authentication_handler
            failure_handler: acme.security.authentication_handler
            always_use_default_target_path: false
            default_target_path:  /
        oauth:
            resource_owners:
                facebook:           /login/check-facebook
            login_path:        /login
            failure_path:      /login
            success_handler: acme.security.authentication_handler
            always_use_default_target_path: false
            default_target_path:  /

            oauth_user_provider:
                service: dm.user_provider
        logout:
            path:       fos_user_security_logout
            target:     /
        remember_me:
            secret:     %secret%

If one knows what could be causing it.. Thank you very much

1

There are 1 best solutions below

0
On

Ok, I got it, for anyone who have been encountering the same storm.

Be careful with ipv6 stuff on your server. PHP curl was trying to do its job through it, but the server was not ipv6-ready, and it eventually found it more cool to step back to ipv4 (but after a long time). My solution was to activate ipv6 completely (DNS, conf, etc.). You've plenty of useful (and short) examples for it on the web.

Have fun!