Skip to content

Asynchrony in the communication to the RTI #303

@byeonggiljun

Description

@byeonggiljun

When the federate terminates, we call socket.end() in shutdownRTIClient() right after sending Resign and LTC signals. Both functions socket.write() and socket.end() are asynchronous, socket.end() may close the connection before socket.write() puts messages into the buffer although socket.end() flushes the buffer before terminating. To resolve this, we may have to manage a variable or buffer to check whether there is any pending data that needs to be sent.

protected _finish(): void {
this.sendRTILogicalTimeComplete(this.util.getCurrentTag());
this.sendRTIResign();
this.shutdownRTIClient();
super._finish();
}

In the CI (which has low computation power), I occasionally see an error ERROR (reactor-ts): Error [ERR_STREAM_WRITE_AFTER_END]: write after end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions