---
schema_version: "1"
id: ffb49bbb558e71629f70fdec95901716811372c3b0c56ae772912cb8ee81827b
title: WebSockets 接続の終了
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/websockets-connector/latest/websockets-connector-connection-close.md
canonical_url: https://docs.mulesoft.com/jp/websockets-connector/latest/websockets-connector-connection-close
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a72c537f15c31fa4db4b9216b6e01ab5fe5bee478db30ff03f40668ff4fbc496
description: MuleSoft Documentation Site
release: "1.0"
latest: true
---
# WebSockets 接続の終了

この操作は、ソケット ID で参照されている現在接続中の WebSockets を終了します。

```xml
<flow name="closeConnection">
    <websocket:close-socket
        socketId="#[attributes.socketId]"
        reason="Quota exceeded"/>
</flow>
```

## [](#close-の出力)Close の出力

この操作は、ペイロードや属性を返しません。

## [](#on-socket-closed)On Socket Closed

メッセージソースは、WebSocket が終了するたびにフローをトリガーします。これは、クリーンアップ操作、ログ記録、アプリケーションの状態の更新を実行する場合に便利です。

これは非同期です。フローが呼び出されるまでに、ソケットは終了しています。参照される WebSocket を介してメッセージを送信しようとすると、エラーが発生します。

```xml
<flow name="onConnectionClosed">
    <websocket:on-connection-closed path="/chat/*" config-ref="ws" />
    <logger
        level="INFO"
        message="No more messages please: you shall not pass." />
</flow>

<flow name="receiveMessagesFlow">
    <websocket:on-inbound-connection path="/chat" config-ref="ws" />
    <logger
        level="INFO"
        message="Someone just sent a message and now I will close this connection!" />

    <websocket:close-socket
        socketId="#[attributes.socketId]"
        reason="I don't like to talk."
        config-ref="ws" />
</flow>
```

path パラメーターは、終了時にフローをトリガーするソケットのパスを示します。​`catch-all`​ を指定する場合、アスタリスクワイルドカード記号 (∗) を使用できます。

## [](#on-socket-closed-の出力)On Socket Closed の出力

この操作は、空のペイロードと属性の WebSocketAttributes オブジェクトを返します。

## [](#関連情報)関連情報

- [MuleSoft ヘルプセンター](https://help.mulesoft.com)
- [Reconnection (再接続)](https://docs.mulesoft.com/jp/websockets-connector/latest/websockets-connector-reconnection)
- [サーバーコンポーネント](https://docs.mulesoft.com/jp/websockets-connector/latest/websockets-connector-server-components)
- [WebSockets Connector の概要](https://docs.mulesoft.com/jp/websockets-connector/latest/)