Repository: bentoml/BentoML

Issue:
bug: Can't connect to bentoml API using websocket
### Describe the bug

Trying to connect to BentoML API service but not working

### To reproduce

Here is my bentoml service:
```
import bentoml
from fastapi import FastAPI, WebSocket, WebSocketDisconnect

app = FastAPI()

@bentoml.service(
    traffic={"timeout": 30},
    resources={
        "gpu": 2,
    },
)
@bentoml.mount_asgi_app(app, path="/")
class WhisperASR:
    def __init__(self) -> None:
        self.__asr_model = ASRModel(model_size="medium")
        self.__vad_model = VADModel()

    @app.websocket("/transcribe")
    async def transcribe(self, websocket: WebSocket) -> str:
        await websocket.accept()
        try:
            while True:
                bytes_data = await websocket.receive_bytes()
                if bytes_data:
                    try:
                        transcription = await audio_transcriber(bytes_data, self.__asr_model, self.__vad_model)
                        await websocket.send_text(transcription)
                    except ValueError as e:
                        await websocket.send_text(str(e))
        except WebSocketDisconnect:
            pass
        except Exception as e:
            raise Exception(e)
```

And here is my client code (trying to fake streaming audio by sending chunks):
```
import asyncio
import websockets
import soundfile as sf
import soxr
import time

async def stream_audio_file(file_path, target_sample_rate, buffer_size, websocket_uri):
    async with websockets.connect(websocket_uri) as websocket:
        # Load the audio file and resample it to the target sample rate
        y, sr = sf.read(file_path, dtype="int16")

        # Resample audio if necessary
        if sr != 16000:
            y = soxr.resample(y, sr, 16000)
        
        # Calculate total number of chunks
        num_chunks = len(y) // buffer_size
        if len(y) % buffer_size != 0:
            num_chunks += 1
        
        start_time = time.time()
        total_elapsed_time = 0

        # Send each chunk over the WebSocket connection
        for i in range(0, len(y), buffer_size):
            # Extract the chunk
            chunk = y[i:i+buffer_size]
            
            # Convert audio chunk to raw bytes
            audio_bytes = chunk.tobytes()

            # Send the audio chunk over the WebSocket connection
            await websocket.send(audio_bytes)

            # Receive and print the transcribed text from the server
            transcribed_text = await websocket.recv()
            print(transcribed_text)

            # Calculate time taken for the chunk
            elapsed_time = time.time() - start_time
            total_elapsed_time += elapsed_time
            start_time = time.time()

        # Calculate average time per chunk
        average_time_per_chunk = total_elapsed_time / num_chunks
        print(f"Average Time per Chunk: {average_time_per_chunk:.2f} seconds")

# Define your audio file path, target sample rate, buffer size, and WebSocket server URI
audio_file_path = "audio.wav" 
target_sample_rate = 16000  # Change this to your desired sample rate
buffer_size = 4096  # Change this to your desired buffer size
websocket_uri = "ws://192.168.34.63:8000/transcribe"

# Start the audio streaming coroutine
asyncio.run(stream_audio_file(audio_file_path, target_sample_rate, buffer_size, websocket_uri))
```
and I got this error:
```
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 500
```

### Expected behavior

I should connect to the bentoml websocket defined

### Environment

bentoml: 1.2.12
python: 3.10
os: ubuntu 22.04


Discussion:

Resolving patch:
diff --git a/src/_bentoml_impl/server/app.py b/src/_bentoml_impl/server/app.py
--- a/src/_bentoml_impl/server/app.py
+++ b/src/_bentoml_impl/server/app.py
@@ -51,7 +51,7 @@ async def __call__(
     ) -> None:
         from starlette.requests import Request
 
-        if scope["type"] not in ("http", "websocket"):
+        if scope["type"] not in ("http",):
             return await self.app(scope, receive, send)
 
         req = Request(scope, receive, send)
diff --git a/src/bentoml/_internal/service/openapi/specification.py b/src/bentoml/_internal/service/openapi/specification.py
--- a/src/bentoml/_internal/service/openapi/specification.py
+++ b/src/bentoml/_internal/service/openapi/specification.py
@@ -96,6 +96,7 @@ class Schema:
     maxItems: t.Optional[int] = None
     minItems: t.Optional[int] = None
     uniqueItems: t.Optional[bool] = None
+    prefixItems: t.Optional[t.List[Schema]] = None
     maxProperties: t.Optional[int] = None
     minProperties: t.Optional[int] = None
     required: t.Optional[t.List[str]] = None


Test patch: