Fixed messaging race-condition bug in remote-ui

Contributed to open source