Are WebSockets Slow on Chrome?

In my last article where I talked about unit testing Socket.IO with Jasmine, there was a point where I mentioned that I needed to use timeouts that were a second and a half when doing the asynchronous connecting and disconnecting from the Socket.IO server. It was working just fine with 750 millisecond timeouts on Firefox, but when I tested it in Chrome, timeouts were being reached and the specs were failing. Let’s see if we can get to the bottom of this and figure out why Chrome failed so hard here.

First I just want to say sorry that this article is late. For those of you who follow me closely, you know that I usually post every Wednesday, but a trip to visit family got unexpectedly extended, and my schedule got out of whack. The timing of this post should be the only problem with the scheduling this week, though. Anyway, on to the important information.

The Gist of My Testing Results

I ran a bunch of tests and honestly, I’m not sure exactly what is causing the problem, but it isn’t necessarily Chrome by itself. I ran the tests in the latest versions of Chrome and Firefox on two different computers with wildly different results. For Firefox on both computers, it took about 1/3 of a second to connect and immediately disconnect a WebSocket connection to a Socket.IO server. Chrome was a very different story, though.

On my PC (with an AMD Phenom II X4 955 CPU), Chrome took over a second to connect and disconnect via the WebSocket transport (I tested multiple transports). On my laptop (with an Intel Core i7 2760QM CPU) it almost always took less than 50ms. It may or may not have anything to do with the processor, but that’s pretty much the only thing I can think of.

Try it Yourself

I saved the tests into a GitHub repository so, if anyone wants to try this out on their machine(s) and possibly try to give me some more insight into this odd issue, it’s there to try out. You can see it here.

If you do try it out, just leave a comment with the results that you found. Instructions for how to get it set up and running are in the README for the project. The test goes through each transport individually, but I’m mostly just interested in the time reported for the WebSocket transport.


I really don’t know what to conclude from this exercise, except maybe that it’s important to test things in multiple browsers on multiple machines. I still need to test to make sure that messages are being passed back and forth from the server at a decent pace because if they are, then it doesn’t really matter how long it takes to connect because an app will only tend to connect one time when it first starts. Anyway, I hope you all can help me find some answers, and maybe we can help make Chrome better. God bless and happy coding!

Author: Joe Zimmerman

Author: Joe Zimmerman Joe Zimmerman has been doing web development ever since he found an HTML book on his dad's shelf when he was 12. Since then, JavaScript has grown in popularity and he has become passionate about it. He also loves to teach others though his blog and other popular blogs. When he's not writing code, he's spending time with his wife and children and leading them in God's Word.