Back to the blog index

How I work around WhatsApp's 4-device limitation


Introduction


While I personally still miss MSN Messenger, unfortunately (or now maybe fortunately?), at least here in Germany, WhatsApp just keeps getting bigger and bigger. Honestly, I find it puzzling. I mean let's face it: They're definitely far from being the best player in the market. The best was MSN anyway, but the only sane explanation I have for WhatsApp's popularity is that, to my knowledge, it was kind of the first mobile-centric messenger of its kind to replace SMS, which has always been outrageously expensive here and they probably had kind of a USP with the idea to use the phone's address book. This way, it might have been some sort of a revolution for those folks who used to keep in touch over SMS as their primary means of communication and I know those have been many. I personally was never one of those. As you might have figured out by now, I'm sort of what I'd refer to as a "hardcore desktop guy". I really love Windows and the open, modding, and especially assembly coding friendly nature of the PC as a platform. I could never really embrace the mobile craze: First, I can still not consider Android to be an actual operating system. It fails to fulfil what's basically pretty much the one and only job of an operating system, according to my operating systems professor at university, which is to distribute resources fairly and equitably between competing applications. When it comes to the microphone, Android fails to do that in a particularly epic manner. That is, the first application gets a real stream from the microphone, other applications just get silence. I mean WTF? I consider myself to be capable of multitasking and so I regularly attend 2-3 calls at the same time. Now try to have a Zoom, Skype, and Telegram meeting with your Android at the same time. It won't work, let alone the fact that it wouldn't really be trivial to setup global gestures to mute yourself within those individual platforms, so there is no chance I'd get through a single day of my life with an Android. So, what else is there? Well, iOS. iOS is actually a real decent mobile operating system, I gotta give that to Apple. However - and if you are a programmer I guess I won't have to explain why - I'm definitely not happy about many of Apple's decisions. For example, I'm still waiting for an official way to use 3rd-party speech synthesizers on watchOS because let's be honest: ESpeak is the only real tool for power users, I'm still waiting for an official way to use WhatsApp on the Apple Watch because WebSockets are artificially blocked and most importantly: I'm afraid of censoring to succeed amongst iPhone users because if they were to, for example, remove Telegram from the app store..., well, sideloading is way too complicated for most people, so I doubt that Telegram would still bother to continue their iOS client. Luckily, this leads me back to Windows and the openness of the PC as a platform: On Windows I can download any random binary from any random person/web page I trust and run it straight away. If I don't trust them, I'm technically always free to disassemble the binary and see what it does on my own. Heck, I can even simply make my own binaries and run them. I can download the MASM32 SDK and start. Dead simple. So, long story short: I am, and I will always be, a desktop guy, or computer guy. Whatever you wanna call me, I'll always prefer Windows over anything else and in a mobile centric world, this keeps getting more and more problematic. So, now, let's concentrate on WhatsApp without further ado.

History


Back in its early days, WhatsApp was so damn mobile-centric that there was no way of meaningfully using it on a computer. Around 2012, when WhatsApp started to gain popularity enough here so that people expected me to use it en masse, this turned out to be a problem for me because of course, I was used to primarily text on a computer and I insisted on continuing. Looking back today, the amount of irony is staggering if I remember how in the early 2000s, I used to hack together an MSN Messenger client for my Siemens phones, particularly the ME45 which I was using for a very long time, not because I liked texting from a phone more back then, but because on rare occasions, it was admittedly better than nothing, although I mostly ended up simply sending lots and lots of voiceclips. God, I'd never have guessed that roughly 10 years later, I'll end up doing the very exact opposite, that is writing a messenger client for my computer. But I did and so I had to reverse engineer WhatsApp, which, at that time, was mobile and mobile only, so I had to enter a territory that was entirely new to me: Smartphone app development. Or, more accurately, smartphone app reverse-engineering. I quickly understood that WhatsApp was based on a customized version of XMPP, running a fork of Ejabberd on the backend. I also figured out how they sort of abused the resource value to differentiate the clients, but they just didn't want to let me connect through multiple resources. This was obviously a problem because, like probably every developer in this world, not only do I have way more than one computer, but also I of course have a phone which - while never becoming my primary means of communication - I still do not want to lock out. Way more important, however, is that I'm an archivist, so I want to keep all of my chat histories in a safe place, where I'm also able to regularly back it up. This practically ruled out the possibility of me just switching between devices while having them share common credentials, as it wouldn't have only been about sharing those, but I would have also had to find a way to synchronize all the chat histories between those devices, making sure nothing gets lost. This might have eventually been feasible with computers only, if you just let them dump those logs onto a common network drive, but again my phone turned out to be the culprit, especially as the 350 kilobytes of "Flex Memory" my ME45 had to offer were practically useless for receiving any meaningful media. Heck, a voice message longer than 2 minutes fucked it from behind. However, long story short, I wanted to keep one computer connected permanently, so that it would continue to keep logs while I can chat through any other device I want. So, I had to find workarounds. My first attempt was pretty obvious: I just registered two WhatsApp accounts: The first one with my real mobile number, the second one with my landline. Next, I created a group for each of my contacts, with both my WhatsApp accounts and that contact inside. As you can probably guess, even though I tried hard to explain what was going on in my then called status, most people didn't understand what was going on, or they found it odd. Either way, most of them left their groups relatively quick. I'd say 50% of them even without sending a single message, so that was a failure. My next attempts have been more successful though. They did of course evolve around the idea of having a server-like software run on the logging machine, which connects to WhatsApp and implements another custom protocol of mine for the other devices/clients. I won't go into more technical details now as this "essay" is already way longer than I was hoping it would get. Oh my fucking god: Taking this walk down memory lane, it is just now that I realize how I've utilized all those vulnerabilities in WhatsApp's protocol to compensate for what their "phone number=user name" approach has actually destroyed! Let me put this straight: If you are as shy as I am, asking a girl for her phone number is the ultimate in tachycardia-causing, sweat-inducing, humiliation-guaranteeing apprehension. Asking for her username however, was totally fine and in no way implied how damn hard you were secretly crushing on her, despite, especially in the case of MSN Messenger, it even let you find out way more about her, simply by snooping on her ever changing statuses. However, gone were those great times and naturally, I began to subconsciously develop solutions to this problem and fill my knowledge gaps. Without a lawyer, I won't go into details of what I did :-) but let me put it this way: In retrospect, it was a very costly endeavor, as I always had to share my mobile data connection with my whole class and just recharge my prepaid balance on the fly whenever it was required so that they'd continue surfing in high speed. If you live in Germany, you know that our providers act like mobile data is gold, so I won't have to explain why this was a problem.


Getting help

Anyway, I finally found a way to use WhatsApp on PC and even through multiple devices. Well, wasn't that the whole point of this post? So now I can stop here right? Not really. First of all, what I had done worked in 2012. I had to regularly patch it to keep up with WhatsApp's changes until 2015 when I could eventually throw it all away. Secondly, it was all depending on my home infrastructure. So when I was let's say on holiday, and my computer lost power or our DSL went down, I was unable to communicate with my server and unable to use WhatsApp. This happened multiple times actually, not only on my holidays but even while I was at school. Lastly, but most importantly however, I really hate shameless self-promoting people, so my goal with this post is not to boast about what I've done, but more to give you something which you'll be able to use for solving this problem for yourself. I just include this history part and spoiler: It will also go for a bit longer - I just include this history part in the hope that it will strengthen the understanding of future developers about how badly they torture people by going mobile-only. Making them see how much time and nerves I had to invest will hopefully prevent things like this from happening again in the future. However: So now I had a solution to my problem but it was far from perfect. Also, it needed constant care. I can't count the iterations I went through from 2012 to 2015. What I want to tell you though is that by that time, Tgalal's yowsup was of extremely amazing help. Fast forward to 2015, and we finally had WhatsApp Web. Damn was I excited! An official way to finally use Whatsapp on a computer, which doesn't even need me to keep patching and losing hours and days just to be able to keep in touch with friends. My prayers have finally been answered, I thought. Spoiler again: Things turned out to not be that easy. First of all, to my knowledge, WhatsApp Web does not support calls to this very day. This became a problem for me in 2017, as a friend of mine didn't have a phone flat rate and thus they preferred calling through WhatsApp. I guess, I can't tell you how dumb it actually feels when you're sitting in front of a powerful desktop, not only with a full-fledged keyboard right in front of you, but even with a high-quality studio microphone, but no, you have to fetch your blody most connectivity constrained (I'll refer to that in a while), most energy constrained (as it's battery powered), most storage constrained device: Your phone, to place a fucking voice call which, in 2017, would technically be supposed to be high-quality anyway. You must experience that yourself to understand me, but I wish you actually never have to. This was my smallest gripe though. The biggest one was the fact that messages still went through my phone. For the record at this point: I finally left Siemens behind in 2013. I really miss their extremely open and modding-friendly platform. With WhatsApp Web, messages still had to go through your phone. If you read thoroughly, you will remember that I referred to phones as the most connectivity-constrained devices. What I meant is that they use either mobile data or WiFi. There is, to my knowledge, no practical way to connect them via a reliable wire, as they have no Ethernet ports and sure, you could use an adapter, but then your charging port would be blocked. I was regularly tempted to set up Android on a Raspberry Pi, but then I would have had sort of an issue every time I got a call. So, yeah, I was tied to WiFi. This turned out to not work well if you, like me, lived in a relatively large house where it's practically impossible to have 100% reliable WiFi coverage. However, that was kind of a constant I couldn't change. So I made do with plugging in my phone as much as possible, forcing the app to stay open, etc. and while I was occasionally still missing messages, it was the best I could do, aside from trying to push people to other messengers, which I started to try kind of aggressively during that time. However, there was also another major gripe, namely that I had to communicate through a browser. Why was that an issue? Well, because modern browsers are just... How shall I put this? Resource heavy. I do actually still have one of my very first desktops: A Pentium 4 with 256 Megabytes of RAM. I mostly keep this machine because of its legendary sound card, which is - at least in my opinion - unrivalled to this very day. In 2017 though, running a browser on this computer was a test of patience. I guess it took like 30 seconds to even start Firefox 52 ESR, which is what you were using on Windows XP at that time. I'm gonna be entirely honest with you: This was not only a problem back then, but today it is even bigger, with more and more modern messengers migrating over to shitty Web technologies, just because their stuff is too lazy to code properly. Anyway in 2018 I finally had enough, so on a certain day, while preparing for my A Levels, after taking lots of medicine to get more performant, I decided to take this into my own hands and so, in a fit of probably the most maximum insanity a human being can reach, I reverse engineered not only WhatsApp, but all messengers I used at that time, implementing their protocols within a single binary, totally hand written in assembly. In the end I had a single EXE file that would connect to Discord, Facebook Messenger, Instagram (for direct messaging), IRC, Skype, Telegram, WhatsApp and XMPP, while using just as little as 504 Kilobytes of memory, consisting of only one comment and code even I barely understand any longer. Of course, in the early days of that questionable creature, I let it log extensively, which eventually led to the by then girl of my dreams giving me a police ban on contact because, I was able to track her online status of Skype in real time, which she perceived as stalking. Then, as you can probably guess, I didn't really feel like continuing its development any longer. Being entierely honest I'm not sure whether I have recovered from that loss even today. However, as that whole thing slowly started to crumble, I was in need of another solution, especially as through that custom client I again did not have a proper synchronization of chat history between multiple computers. Looking back I gotta admit that I could've probably synced it up to my phone, especially as WhatsApp Web allowed for fetching history but hey, I was heartbroken, so continuing the development of what brought me into that situation in the first place was the last thing I wanted to do. So, I started to look into alternatives. I went through pairing whapp-irc with an IRC-XMPP-bridge which served as a bouncer and multiplexer for my multiple devices, later on it was sms-irc, then finally whatsxmpp, which was a native XMPP bridge. But in 2021, things should get even better...

Back on my own?


While I was extremely stressed by the exams of the summer semester of 2021, I hardly perceived it, but luckily I took a little note somewhere in my subconscious when wabetainfo.com announced that WhatsApp is now introducing something they call "multi device". I'd rather call it "four-device", because that is practically what it is: Okay, they proudly tell you that you can now use your WhatsApp account with up to five devices at the same time, but if you actually look at the fine print, you'll immediately notice that one of those is your very damn phone which you've been forced to use as your primary device for almost a decade (for some people probably over a decade as WhatsApp was founded in 2008) anyway. That doesn't count for me, especially as today I have my Apple Watch, given I had a choice, I wouldn't use that slot for my phone, as it is now probably my least-used device. When I'm home, I still use a computer and when I'm not, I mostly draft quick replies on the watch, or I just send voiceclips. It's effectively 4 devices. But what if you are a developer? I am, and I am particularly fascinated with OS/Kernel/Driver development. As such, I do of course require lots of diverse hardware and so, I have roughly around 30 totally different computers, ranging from a Pentium 3 to the latest and greatest from Intel and AMD. I like to test my software on the weakest of them, wherever applicable, because when it's acceptable there, it's gonna fly on the modern stuff and belive me: The customers realize it when your software is faster than anything they've ever seen before. Furthermore, for mobile development and reverse engineering, I also have around 10 phones, both iPhones and Androids even though I hate the latter, and even 2 Apple Watches. Now, is it really too much to ask if I just want to be able to answer my chats from all of those devices and also be able to access their histories? I don't see why it should be. Literally any other messenger manages to do this out of the box. Discord never had a problem with multiple devices and Telegram even boasts in their FAQ that you can use it on unlimited devices. So, when the maintainer of whatsxmpp made it clear that he was not going to port the bridge to WhatsApp's newly upcoming multi device protocol, it appeared to me like I'd have to tackle it on my own again. This time, having learned from the past, I didn't want to just write a client, but rather some sort of bridge. But I did not really feel like hosting my own XMPP server. I was using whatsxmpp on the server of a very very good friend of mine, namely Martin, who is the co-founder of hot-chilli.net and they also have an amazing XMPP server at jabber.hot-chilli.net. If you ever need XMPP, also under your own domain, I would definitely highly recommend them to you. However, in my case, even though I was sure that Martin would've hosted my bridge if I had developed one, it would have been a pain for both of us to debug as I wouldn't have had direct access to his server. At that point I was about to just start over with what I did in 2012: Write a custom protocol to communicate with a computer of mine, But then I had an inspiration.

The idea


In one of my study projects, the other developers were pretty pushy for WhatsApp. Even though I created a Discord server, they mostly used WhatsApp for communication, so I needed a quick and dirty solution for this. By chance, while doing my research for a WhatsApp XMPP bridge, I stumbled on a program called Matterbridge. Technically, they claimed to even support WhatsApp directly. However, I never really got my head around their complex config and I also had no need to, because, as I said, I was in need of a solution for a "now-problem". So I needed something immediately, not necessarily something which was future-proof. So I realized that, since the old WhatsApp Web API was still around, it shouldn't be too hard to get my old assembly client from 2018, update the WhatsApp part as needed and effectively turn it into a Discord-WhatsApp bridge. Within probably half a day, I had thrown together something that worked. Well, it crashed like once every 2-3 days, but hey, at least one of the other developers had both WhatsApp and Discord on their phone, so they noticed it when they sent a WhatsApp message and there was no notification on Discord, and then they wrote me in private. All in all, it was a totally working solution, except for one group. There was no direct messaging, handling of files wasn't the best, etc. However, now the idea of just bridging to other conventional services was already in my head. Like: I realized that XMPP wasn't the only option I had. So I did a little brainstorming as I thought, especially given Discord's filesize limitation of 8 MB back then, Telegram might be a better choice. Unfortunately I couldn't because I soon figured out that Telegram bots can't, at least to my knowledge, create groups and add people on their own. But hey, bots can totally create channels in Discord servers. So, my idea was finalized. Well, to be fair, it was not my idea, as someone else was faster than me, but I wasn't aware of that at this point. So, I searched the internet for "WhatsApp Discord Bridge" to get some inspiration for the name of my project. I thought similar things like Matterbridge might exist between those two services in particular, however, definitely not the way that I want mine to be, so that it can totally replace your real WhatsApp client while giving you Discord's true multi-device support. I needed a proper name for my project, as this time - I thought - I will definitely write it in a more understandable manner and I will also put it on GitHub, hoping that some other dedicated ballers might help me keep it in sync with WhatsApp's servers. Me being me however, the language was out of the question, it would be x86 assembly. I would never sacrifice performance for human blabla. I am proud to be a real coder and not a script kiddy after all. So after typing "WhatsApp Discord Bridge" into my search box and pressing Enter, I was in for a surprise: I found a project called WhatsApp to Discord by Fatih Victor Kilic (FKLC). This freaking genius not only had the idea before me, he has even implemented it, so for me there was nothing left to do except just getting that up and running and calling it a day.

2023


Fast forward to 2023 and I am not only a happy WA2DC user, but even a contributor. Well, to be fair I just bumped up the outdated version of Baileys (the "WhatsApp Library") as it got old enough for Meta Platforms, Inc. to pull the trigger on the server side, but I will definitely contribute way more in the future. Also I have given Fatih - whom I would now consider a good friend - many ideas which he realized, for example supporting Discord's native voice messages. Well, at least you can now send them from Discord. Having WhatsApp's voice messages come through as native voice messages in Discord as well is probably something that I am gonna implement soon. Maybe he'll read this and be faster again. :-)

The finishing touches


Now that I had a working solution, I did of course find some quirks which made it... let's say imperfect, especially because Discord is also not the most efficient messenger in the world. Hell, it's based off webshit! On the other hand let's face it, the one and only messenger I'm aware of still existent today which is not based off webshit is actually Telegram. They're the only one still delivering a real C++ application. And as far as Discord is concerned, I have a custom client anyway, so what? On top of that, in 2019, I even discovered that Miranda NG used to support Discord. That's also something I've been using for almost a decade on XMPP. However, I correctly said Miranda used to support Discord. They had to officially remove Discord support because their lead developer regularly got banned. Heck, even I got banned while reverse-engineering, twice in a row, but luckily I managed to convince the company to re-establish my account. Anyway not only was it clear that I should have a Plan B in case Discord ever kicks me out, but furthermore, at least on my most important desktops, I wanted to have more of that MSN Messenger feeling back. That is, getting alerts as my contacts come online, being able to see when they're typing, etc. And since I have done a hell of a lot of research about WhatsApp bridging anyway, I found purple-gowhatsapp, which today should probably be called purple-whatsmeow. It is a WhatsApp Plugin for libpurple. The maintainer primarily wrote it for Pidgin, but Martin also used many transports based on Spectrum, which in turn also has a libpurple backend. So, I contacted the developer of purple-gowhatsapp and worked closely with him to implement Spectrum compatibility. Now, I not only have a transport, but also another great friend.

Conclusion


I now have multiple ways to access WhatsApp, all with advantages and disadvantages: First of all, I have the Discord bot, which effectively solves the multi-device problem, probably in the most elegant way possible. I mean, I can literally just go to the next computer in a library, log on to Discord in a browser and chat. Secondly I have the XMPP bridge, which I prefer for most direct message conversations. Group chats can be a bit problematic sometimes with Spectrum, XMPP, and plugins, especially when it comes to media in the group. Generally, when it comes to media, XMPP is definitely not the best because there is, for example, to my knowledge, no standard on how to send voice messages, so you could end up having a client send an M4A, while WhatsApp for example expects Opus. However, since on XMPP I have typing and online presences, it just feels a bit more natural to me, who still misses MSN Messenger, which is why I prefer XMPP for DMs. My 3rd slot is occupied by an official instance of WhatsApp for Windows. This is primarily so that I can have calls on a computer, but also I gotta admit the accessibility of the client is pretty good in the meantime, at least since 2022 when I installed the beta to have group voice calls. I never tried a non-beta again though to be fair. However, you can still feel that it is an application which was built for phones from the ground up. Especially when it comes to the online status: It shows you as online when the application is focused. For me, coming from MSN, online rather means someone's computer is actually running and they have interacted with it just recently. My last slot is currently occupied by WatchChat, a WhatsApp client for the Apple Watch, which is also developed by a really good friend of mine. However it is actually switching between WatchChat and my own assembly client, which I occasionally still update, just in case... After all, WatchChat unfortunately still doesn't work on its own, meaning the iPhone must be in either Bluetooth or WiFi range of the watch. And since I like the idea of leaving my iPhone at home when I go swimming, this is kind of a deal breaker for me. However, I know that the developer is aware of that. In the meantime, the developer of Minicord (an Apple Watch client for Discord) is also struggling to implement voice messages. The significant advantage of this is that unlike XMPP (remember the WebSocket restrictions), Discord can run natively on the Apple Watch and this way, I could reserve my last slot entirely for my own development, so with this, let's see who's gonna be faster. After all, it's certainly not bad to have options.

Final words


Even though, as you'll definitely know if you really read through all this, WhatsApp probably took me, if I sum it all up, a year maybe? I guess I should be thankful for the situation I'm in now. I have nice opportunities to stay in touch on all devices that I want now. And while I went through hell to get this, at least now I'm there. And I recently had a discussion with people from the US, who explained to me that out there, iMessage is actually a thing. Oh and not only that, but also RCS, the modern successor of SMS. God save them, really! As far as iMessage is concerned, I have still to find a valid way of running this on Windows, without having a Mac as a middleman or routing it through a phone. This is also why I tend to say: "If you want me to hate you, just send me an iMessage." And as far as RCS is concerned, father in heaven: If this was a thing here, our providers would just exploit us the same way they've done with SMS before. So, I can only be infinitely thankful for my situation. And no matter how much we like or dislike WhatsApp, I think we all should appreciate it. Because, sure, to reference my introduction : While WhatsApp is certainly by far not the best player in the market, there are also some that are way worse.

TLDR


If you are a developer or a technically-inclined person and you struggle with WhatsApp's 4-device limitation like I do, I highly recommend using WhatsApp to Discord.