I'm experiencing the same error. I'm also using a demo account with the XM broker. I don't know if the problem is because the account is a demo.
I implemented it in both Python and Node, but the same problem. Sometimes it works, sometimes it doesn't. When the timeout occurs, it stays for a while and then goes away. But it always comes back.
I've already sent a message to MetaAPI support, but haven't received a response.
I'm trying to see what can be done because I need a way to control my MetaTrader account with Python/Node through a Linux operating system. It's really annoying that I can't use the official MetaTrader library in Python for Linux, only Windows.