Skip to content

Commit

Permalink
Merge pull request #268 from pipecat-ai/aleix/websocket-dont-send-if-…
Browse files Browse the repository at this point in the history
…closed

transports(websocket): don't send data if websocket closed
  • Loading branch information
aconchillo authored Jul 1, 2024
2 parents e8f5893 + c3244fd commit abd65a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
processing metrics indicate the time a processor needs to generate all its
output. Note that not all processors generate these kind of metrics.

### Fixed

- Fixed an issue in `FastAPIWebsocketTransport` where it would still try to send
data to the websocket after being closed.

## [0.0.35] - 2024-06-28

### Changed
Expand Down
3 changes: 1 addition & 2 deletions src/pipecat/transports/network/fastapi_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typing import Awaitable, Callable
from pydantic.main import BaseModel

from pipecat.serializers.twilio import TwilioFrameSerializer
from pipecat.frames.frames import AudioRawFrame, StartFrame
from pipecat.processors.frame_processor import FrameProcessor
from pipecat.serializers.base_serializer import FrameSerializer
Expand Down Expand Up @@ -114,7 +113,7 @@ async def write_raw_audio_frames(self, frames: bytes):
frame = wav_frame

payload = self._params.serializer.serialize(frame)
if payload:
if payload and self._websocket.client_state == WebSocketState.CONNECTED:
await self._websocket.send_text(payload)

self._audio_buffer = self._audio_buffer[self._params.audio_frame_size:]
Expand Down

0 comments on commit abd65a9

Please sign in to comment.