It is somewhat weird, but sometimes socket 'message' writes two events simultaneously which crashes nodejs server, since it cannot parse them as valid json. I suppose this happens because the simulation is quite fast and somehow manage to send two event simultaneously to SocketWriter which somehow #2 merges them into one socket write... Currently the workaround is to add a timeout after an event that is emitted to the socket writer but it is not good as it slows the simulation...