How do Alice and Bob perform key exchange through a third-party (server) in end-to-end encryption? Understanding end-to-end encryption, I ran into an issue which I wasn't able to find a solution for.

Given three parties: Alice, Bob, the chat endpoints, and the server party owned by Eve. The server party allows Alice and Bob to communicate.

Let's say Alice and Bob wanna start an encrypted chat session with each other. How do they prevent Eve from gaining and replacing the encryption keys (performing the MiTM attack) and compromising the whole session?

A meeting in person to share the secret is not an option.

I have read about OTR and Double Ratchet Algorithm. They claim to be secure and OTR claims to use the Socialist millionaire protocol, which, as I understand, should prevent the conversation to be compromised. But I don't quite understand how it works.

The main question is, is there a way for two parties establish a completely private conversation though a compromised server without using an outside channel?
If Alice and Bob have no relevant secret knowledge not known to eve which controls the communication channel between them, it is impossible to create a seecure communication channel.
Any protocol used, including diffie hellman, double ratchet socialist millioner or anything else can still be used with a MITM attack. 

Eve takes the role of Bob when talking to Alice and the role of Bob when talking to Alice. Agreeing on two separate keys. The socialist millionaire will do no good because Bob shares a key with Eve.

To make this work we need either a pre shared public key for at least one party or a secondary communication channel to verify same key is used. We could use a public channel which everyone sees but Eve does not control. We could meet IRL and compare keys. We can use a voice channel assuming Eve won't be able to synethesize our voice in real time to recire a key commitment.(Deep learning is rapidly making the last assumption dubious).

Key exchange protocols work great with a passive eves dropper or when we have an authentication mechanism.