Solved: Laravel Event Broadcasts Not Arriving at Pusher

The other day I was getting some hands-on experience with Laravel 5.1’s event broadcasting features. I followed all the requirements specified by the documentation. However, when my application would broadcast the event, it would not reach Pusher.

During my debugging process I confirmed that:

  1. I had Pusher’s composer package pulled into my app.
  2. I was using the proper api keys provided by Pusher.
  3. My event class implemented Illuminate\Contracts\Broadcasting\ShouldBroadcast contract
  4. My event class used the Illuminate\Queue\SerializesModels trait.
  5. My event was firing the event that was to be broadcasted.
  6. That my broadcast was being sent out through the queue.
  7. That my javascript was properly receiving events triggered by Pusher’s debugging console.

At this point my brain is screaming “WTF?”

I decided to go into the source code of Pusher’s composer package. I placed a var dump inside the exec_curl() private function which then spit back the following:

[body] => Timestamp expired: Given timestamp (2015-06-15T03:30:47Z) not within 600s of server time (2015-06-15T03:41:33Z) [status] => 401

Ah hah, now we’re on to something.

I took to the web to see what I could find which led me to this stack overflow topic. This began to make sense. If you ever worked with Windows Domain Controllers there is a Kerberos Authentication process that is reliant on a NTP (network time protocol) threshold. Well the same can be said for Linix/Unix when it came to how Pusher authenticates requests. I took the command mentioned on Stack Overflow and ran it inside of Homestead:

sudo ntpdate ntp.ubuntu.com

And as you would expect it fixed the problem entirely. I’m sure some other Homestead users will more than likely encounter this problem at some point. So enjoy the solution :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>