Socket.IO Android — HTTPS/SSL

Enable HTTPS secure connection to Socket.IO and Android

If you are going through the Socket.IO HTTPS connection issue on Android by following the Socket.IO official tutorial https://socket.io/blog/native-socket-io-and-android.

You have to do some changes to your project to make it work.

First of all, if you have followed the above official reference from Socket.IO you might have included the library as below which is no longer valid.

It seems the Socket.IO official documentation is not that much updated.

You need to implement the below library instead of the above one.

Then you are good to import or replace the imported libraries from the previous one and just make sure your project works with HTTP well as earlier.

Finally, you have to set the HTTPS context and OkHttpClient to your IO options, in order to complete this you can copy the helper class which I’ve hosted in Gist.

Simply you can now pass the Socket Options to the set() method to set all the SSL context which enables your Socket.IO to communicate with HTTPS servers.

Here is a working example for your reference.

Thank you ✌️ I’m Aslam Anver find me on GitHub and StackOverflow as aslamanver & Googlian

Passionate in AI Deep Learning, Find me on GitHub & StackOverflow