Skip to content
This repository was archived by the owner on Sep 25, 2023. It is now read-only.
This repository was archived by the owner on Sep 25, 2023. It is now read-only.

WebSocket session is not closed after all expected messages were received #75

@kuzznya

Description

@kuzznya

Existing WebSocket session is not closed after processing all expected messages with such configuration:

server.expect().withPath("/ws")
    .andUpgradeToWebSocket()
    .open()
    .expect("input")
    .andEmit(new OutputStreamMessage("output"))
    .once()
    .done()
    .always();

If my understanding is correct, session should close after "input" is received (if not, please correct me and I'll close the issue). This is not happening due to the check in io.fabric8.mockserver.internal.WebSocketSession::closeActiveSocketsIfApplicable:

public void closeActiveSocketsIfApplicable() {
        if (pendingMessages.isEmpty() && requestEvents.isEmpty() && httpRequestEvents.isEmpty()
          && sentWebSocketMessagesRequestEvents.isEmpty()) {
            activeSockets.forEach(ws -> ws.close(1000, "Closing..."));
        }
 }

i.e. requestEvents.isEmpty() - it is never empty when there were some expected messages because even after receiving expected message it still contains entry "input": <Empty queue>

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