long time ago looked this problem but resolve it by sql queries directly from confing file to location table.
So while remember
lookup(location) ofen can not find any contacts if its registers from websocket.
it may work 10-15 times and then fails. So debug shows answer that is no connections in location table.
Now at production system can not run this issue but at development system want to do it today or tomorrow.