Scott Watermasysk

Still Learning to Code

Using Twilio Client and Pusher Together

Last week I started building a fun new project, DearEmmy (more on this shortly). DearEmmy makes use of Twilio’s new client feature as well as Pusher for real time updates.

Everything was going great, until I fired up Internet Explorer[1] and saw just about nothing in the app was working.

As a good web developer, my first thought was, damn you IE. After digging through the errors, they seemed to point to a conflict between Twilio and Pusher.

After a couple of support emails I learned both Twilio and Pusher are using the websocket-js library. This library enables browsers without websocket to act like real browsers and most importantly, there was indeed a conflict.

Both companies have acknowledged the bug and hopefully by the time you read this it will be resolved (look for an update below).

However, for better or worse I am impatient and started to look for a fix. I tried various methods of loading the scripts on demand which didn’t work. I then moved the Pusher scripts to an iframe to isolate them from the main page. This worked great in Safari/Chrome, but failed in the same miserable way in IE and FF.

Then, on a whim, I decided to swap the script order. Instead of loading Twilio first and Pusher second, I changed it to load Pusher before Twilio. And now, everything works in IE, FireFox, Safari, and Chrome.

I really hate not knowing why this worked, but I am confident the smart folks at Twilio and Pusher will figure it out. I can now go back to getting real work done.

[1] I later learned the bug also exists in FireFox which pretty much confirmed it was related to flash…damn you Adobe.