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

Use option proxy even at HeartBeat #78

Closed
BigOHenry opened this issue Sep 18, 2019 · 9 comments
Closed

Use option proxy even at HeartBeat #78

BigOHenry opened this issue Sep 18, 2019 · 9 comments
Labels

Comments

@BigOHenry
Copy link

Hello,
we are using Vies with proxy. Getting data from vies is fine, but HeartBeat does not work.

$option = array(
            'proxy_host' => $this->https_proxy['host'],
            'proxy_port' => $this->https_proxy['port'],
            'proxy_login'    => $this->domain_user['user'],
            'proxy_password' => $this->domain_user['password']
        );
        $vies->setOptions($option);

        if (false === $vies->getHeartBeat()->isAlive()) {
            $vat_numbers_data['result'] = 'VIES - Service is not available at the moment, please try again later.';
            $this->serviceModel->insertApiCallResponseLog($id_request, 500, [$vat_numbers_data]);
            return true;
        } else {
// do more
}
@DragonBe
Copy link
Owner

Hi @BigOHenry,

Thank you for reporting the issue. To be honest, I never thought of using this library through a proxy. So initially I never designed the library to facilitate this functionality.

I've labeled your issue as a feature and will work in the upcoming weeks on it.

@BigOHenry
Copy link
Author

Thank you very much :)

@drupol
Copy link

drupol commented Feb 14, 2020

We can use PSR-18 for abstracting the HTTP client !

@DragonBe
Copy link
Owner

Hey @drupol,

I've done it already in my other library dragonbe/hibp, but never got around to implement it here. Do you think you have some time to look into this?

@drupol
Copy link

drupol commented Feb 14, 2020

Hey @drupol,

I've done it already in my other library dragonbe/hibp, but never got around to implement it here. Do you think you have some time to look into this?

I personnaly don't need the feature but I can help doing it for sure :-) I'll see if I can give it a try this weekend!

@drupol
Copy link

drupol commented Feb 14, 2020

Here's a first shot: https://gist.github.com/drupol/8e541083763b0f5a4b6d816684f0e0d0

As you can see, you pass the HTTP client in the constructor, and it can be configured at will by the user (proxy, etc etc).

Let me know what you think.

@DragonBe
Copy link
Owner

Hi @BigOHenry,

I've taken a look at this and there was a major issue in the design of the heartbeat feature. In our current situation we just wanted to make sure we could "reach" the service directly.

@drupol I've taken a look at your proposed change, but at this point this library is used in projects that are not yet implementing PSR-18. I do want to rebuild it using PSR-18 in the next major version of VIES, but not for now.

I've modified the logic within DragonBe\Vies\Heartbeat a little bit so you can provide it with your custom proxy settings.

$vies = new Vies();
$options = [
    'proxy_host' => '127.0.0.1',
    'proxy_port' => '8888',
];
$vies->setOptions($options);

$heartBeat = new \DragonBe\Vies\HeartBeat('tcp://' . $options['proxy_host'], $options['proxy_port']);
$vies->setHeartBeat($heartBeat);

$isAlive = $vies->getHeartBeat()->isAlive();

As I used a local proxy for testing, I can see the requests being handled through my proxy correctly.

VIES Service over Proxy

@BigOHenry please have a look at PR #101 for my suggested changes and tell me if this will work for you. Once reviewed by @krzaczek we can implement it and release it to the masses.

@drupol
Copy link

drupol commented Mar 22, 2020

Hello mate,

It's fine, no worry. Let me know if you need some help for using PSR-18.

Thanks for your feedback !

@DragonBe
Copy link
Owner

Hey @drupol,

Now with the "extra" time I got due to "social distancing" and "covid-19 measures" I do have plans to work on a full upgrade of the library so we can make use of PHP 7.4 features and separating logic even further. Also a clean up of repeated logic over the various validators is in the pipeline.

More on that once I have decided on the roadmap of the project.

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

No branches or pull requests

3 participants