Moesif / moesif-slim

Moesif Middleware for Slim Framework
Other
1 stars 1 forks source link

No exec rights on shared hosting #1

Closed CaseyRo closed 3 years ago

CaseyRo commented 3 years ago

Hi dear Moesif team!

I've tried to setup Moesif for my slimphp API yesterday, and of course it worked fine on develop - but not on production.

This is the error returned;

The "exec" function must exist to use the cURL consumer in "fork" mode. Try setting fork = false or use another consumer.

How do I set this 'fork' mode and what's the impact? The documentation for moesif-slim doesn't mention it.

Thanks.

dgilling commented 3 years ago

Hi @CaseyRo , When this error happens, it means the PHP installation doesn't support the exec command. What is your production environment running on? Are you able to enable the exec function with that PHP installation? Some providers allow this (like NameCheap and DigitalOcean) and some don't. There are two ways to fix:

  1. If possible, the recommended way is to enable exec() (an example for Digital Ocean is here). This enables the best performance for high volume APIs.
  2. If your API is not high volume, you can also disable forking in the SDK. Looks like our Laravel SDK supports this flag, but not our Slim SDK. We should have an update shortly to support this as a workaround if you cannot perform 1.
CaseyRo commented 3 years ago

@dgilling which pretty much means that if I would change $fork = false a few lines above (so it skips the if statement all together) that would do it? happy to change the code myself - don’t know the impact on the rest of the code of course!

dgilling commented 3 years ago

Hi @CaseyRo , we released version 1.1.0 which supports disableForking. See this section.

CaseyRo commented 3 years ago

wonderful @dgilling! I’ll test it out ASAP!

CaseyRo commented 3 years ago

@dgilling sorry to re-open, the fix unfortunately led to the next step; line 58 in sendcurltaskcustomer.php in moesifapi-php -->

if ($this->_fork == true) {

dgilling commented 3 years ago

Hi @CaseyRo, I didn't understand the comment. Was there an issue with that line?

CaseyRo commented 3 years ago

@dgilling sorry for the confusing response.

Version 1.10 of moesif-slim solved the exception message with the configsetting of ‘disableForking’, but this is not yet supported by moesifapi-php, that still throws the exception from line 58 in sendcurltaskcustomer.php.

dkm199 commented 3 years ago

@CaseyRo from our testing, we see moesif-slim(1.1.0) latest version and moesifapi-php(v1.1.10) version are compatible and should work with disableForking configured to true without any manual changes. So To debug this, can you share below with us. 1) output of composer show which tells us what is the moesifapi-php used 2) also can you please double confirm that you have disableForking flag set to true

CaseyRo commented 3 years ago

sure here goes:

from my CI log:

Screenshot 2021-03-19 at 20 27 38

and the config file:

<?php
return [
  //
  'applicationId' => 'eyJhcHAiOiIxOTg6MTIxOCIsInZlciI6IjIuMCIsIm9yZyI6Ijg4OjE3MjUiLCJpYXQiOjE2MTQ1NTY4MDB9.hLUJLEHKPDrpY2NfHmpu6y1FDTokDo50muKv1-EL0uQ',
  'logBody' => true,
  'disableForking' => true
];
dkm199 commented 3 years ago

@CaseyRo Keyur who owns the sdk, tested this on a fresh vm, and he was able to integrate with Moesif without any issues, so not sure why we are not able to reproduce the errors at our end. Are you open to having a shared debug session with us? If so, let us know your preferred email and some times that would work for you to set up a meeting. Thanks

dkm199 commented 3 years ago

@CaseyRo just checking if this is still an issue

dkm199 commented 3 years ago

closing this as no reply. Please reopen if needed