1

Hard to provide the right information for this. Been at it for days. I have Pusher working well in Vagrant. I stand it up with a basic Horizon config (prod/local doesn't matter):

 'production' => [
        'supervisor-1' => [
            'connection' => 'redis',
            'queue' => [
                env('DEFAULT_QUEUE', 'default'),
                env('COMMENT_EVENT_QUEUE', 'comms')
            ],
            'balance' => 'auto',
            'processes' => 10,
            'tries' => 3,
        ],

All of this is behind Stancl Tenancy for Laravel. And it all works works fine. I have stood up the exact same system on a production box. That works fine too.

I have now installed same in a business that complicates things with a load balancer and SSL on top. So my box sees only http traffic in the last mile. I use \URL::forceScheme('https'); in boot to make everything play nice, and it works.

I start Horizon from Supervisor using this conf file:

[program:horizon] 
process_name=%(program_name)s 
startsecs=0
command=php /var/www/er2/artisan horizon
user=www-data
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/www/er2/storage/logs/horizon.log
stopwaitsecs=3600

Problem:

Running Horizon (or queue:work) through supervisor FAILS to send pusher msgs with the following error:

{"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): at /var/www/crisis/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:121)

Here's the kicker: if I start Horizon (or queue:work) from the command line, it works. It is only when I start it with Supervisor that it fails.

Anyone have an idea where to start?

What I've tried:

  • Changing users in Supervisor -- still fails
  • Changing Supervisor to start queue -- Still fails
  • Changing to root on command line -- still works
  • Changing workers -- still fails if Supervisor
  • A bunch more but nothing makes a difference.

Dumping vars all over the vendor files, the only difference I can find is:

With Supervisor (fail):

RESPONSE --> {"body":false,"status":0}

With Command Line (success):

RESPONSE --> {"body":"{}","status":200}

I can't narrow down what is different for Pusher when Horizon is started from Supervisor vs command line. Any thoughts?

Watercayman
  • 7,970
  • 10
  • 31
  • 49
  • Is the Pusher server logging any of these requests? – levi May 30 '20 at 00:28
  • From the pusher debug console - it logs all successful requests from horizon started from cmd line. Nothing shows up with supervisor running it. – Watercayman May 30 '20 at 00:31
  • Seem like the HTTP requests to Pusher server are failing. Have you tried logging the Pusher url/port in supervisor initiated script, to verify its correct? – levi May 30 '20 at 00:34
  • Assuming its correct, are you able to make other successful outgoing HTTP requests from supervisor initiated script? – levi May 30 '20 at 00:36
  • Shoot - that's a great idea. I haven't tried to make other https requests from supervisor. Will try that. How would I log the Pusher url/port from supervisor? How can I capture this? – Watercayman May 30 '20 at 00:37
  • `config('broadcasting.connections')` – levi May 30 '20 at 00:41
  • Thanks Levi. looks like http is not working from supervisor, but I'll need to test further. You may have pointed me in the right direction after days of banging my head. – Watercayman May 30 '20 at 00:46
  • Great. One last thing, when defining pusher driver in config, under the options array, you can add `"debug" => true`, and this should result in Pusher passing back more detailed error. – levi May 30 '20 at 00:48
  • Doh - that's huge! I totally missed that. Thank you very much again. – Watercayman May 30 '20 at 00:50
  • I'm guessing this is your issue - https://stackoverflow.com/questions/47083582/supervisor-not-using-etc-environment – levi May 30 '20 at 00:53
  • Wow. it sure sounds like it could be. If it's that easy, after all this work, I'll be thrilled. I'll investigate. Fantastic. Thank you. – Watercayman May 30 '20 at 00:54

0 Answers0