Socket.IO Android — HTTPS/SSL

If you are going through the Socket.IO HTTPS connection issue on Android by following the Socket.IO official tutorial

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.

implementation '

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

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

👍implementation ''

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.

IO.Options options = new IO.Options();
Socket mSocket = IO.socket("", options);
mSocket.on("message", onNewMessage);

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



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aslam Anver

Aslam Anver

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