blackfireio / php-sdk

The Blackfire PHP SDK
https://blackfire.io
MIT License
150 stars 22 forks source link

401 when profiling local apps #13

Closed AdamKyle closed 8 years ago

AdamKyle commented 8 years ago

I have followed the instructions to set everything up but alas I get the error:

  [Blackfire\Exception\ApiException]                                                                                                      
  401:  while calling GET https://blackfire.io/api/v1/collab-tokens [context: NULL] [headers: array (                                     
    0 => 'Authorization: Basic xxx',                                                                                                       
    1 => 'X-Blackfire-User-Agent: Blackfire PHP SDK/1.0',                                                                                 
  )]  

Can you explain whats going on? Ive replaced the auth with a series of x's

lyrixx commented 8 years ago

Hello Adam.

Because we will need more information and theses information might be private, could you use the feedback form on https://blackfire.io/ ? Thanks.

jean-louis commented 8 years ago

Hi, sorry for my bad english.

I have the same problem and in my case is due to an undefined HOME environment variable.

Without the HOME variable the values from ~/.blackfire.ini isn't loaded.

if it can be usefull to someone, I have solved by adding SetEnv in my virtual host (apache)

<VirtualHost hostname:80>
   ...
   SetEnv HOME /home/vagrant
   ...
</VirtualHost>

now is needed to restart apache.

P.S. you must have the mod_env extension enabled:

sudo a2enmod env

MatrixOfDeath commented 6 years ago

Hello, same issue for me I'm using the docker agent that's is running, the profiling goes to 100% and then analyzes data but no view profile button. When i check the logs of my blackfire containers I get this:

blackfire_1  | [2018-01-24T18:34:23Z] ERROR: The Blackfire API answered with a 401 HTTP error ()
blackfire_1  | [2018-01-24T18:34:23Z] ERROR: Error detected during upload: The Blackfire API rejected your credentials.

PS: I'm using a Debian9 VM and dockerised nginx, php7, symfony2.8, dbmysql8, redis

Regards

romainneutron commented 6 years ago

Hello , As mentioned above, please contact the support team on https://blackfire.io instead of commenting here.

pashak09 commented 3 years ago

I had the same error. I just set the environment variables

BLACKFIRE_SERVER_ID: ~
BLACKFIRE_SERVER_TOKEN: ~
BLACKFIRE_CLIENT_ID: ~
BLACKFIRE_CLIENT_TOKEN: ~

Which you can find in your account settings

efeferrari commented 2 years ago

I tried @pashak09 fix and it works perfect 👌🏼 Thanks!

nuryagdym commented 2 years ago

I had the same problem on docker env. PHP-FPM services was in one container and blackfire agent in another service. My mistake was defining all blackfire environment variables to blackfire agent service only. Instead it should be in this way:

app-php:
    image: php
    environment:
      BLACKFIRE_CLIENT_ID: #add your clientId 
      BLACKFIRE_CLIENT_TOKEN: #add your client token
app-blackfire:
    image: blackfire/blackfire:2
    ports: ["8307"]
    environment:
        # Exposes BLACKFIRE_* environment variables from the host
        BLACKFIRE_SERVER_ID: #add your serverId
        BLACKFIRE_SERVER_TOKEN: #add your serverToken

BLACKFIRE_CLIENT_ID and BLACKFIRE_CLIENT_TOKEN are used by blackfire/php-sdk package.