Skip to content

Server rejected WebSocket connection: HTTP 404 #152

Open
@N4RLY

Description

@N4RLY

I took code from the first example in readme file:

from codeinterpreterapi import CodeInterpreterSession, settings

# create a session and close it automatically
with CodeInterpreterSession() as session:
    # generate a response based on user input
    response = session.generate_response(
        "Plot the bitcoin chart of year 2023"
    )
    # output the response
    response.show()

And got this traceback:

Using Chat OpenAI
Starting kernel...
Waiting for kernel to start...
Attempt 1: WebSocket connection failed. Error: timed out during handshake

---------------------------------------------------------------------------

InvalidStatus                             Traceback (most recent call last)

[<ipython-input-5-7a437c822d36>](https://localhost:8080/#) in <cell line: 4>()
      2 
      3 # create a session and close it automatically
----> 4 with CodeInterpreterSession() as session:
      5     # generate a response based on user input
      6     response = session.generate_response(

7 frames

[/usr/local/lib/python3.10/dist-packages/codeinterpreterapi/session.py](https://localhost:8080/#) in __enter__(self)
    485 
    486     def __enter__(self) -> "CodeInterpreterSession":
--> 487         self.start()
    488         return self
    489 

[/usr/local/lib/python3.10/dist-packages/codeinterpreterapi/session.py](https://localhost:8080/#) in start(self)
     88 
     89     def start(self) -> SessionStatus:
---> 90         status = SessionStatus.from_codebox_status(self.codebox.start())
     91         self.agent_executor = self._agent_executor()
     92         self.codebox.run(

[/usr/local/lib/python3.10/dist-packages/codeboxapi/box/localbox.py](https://localhost:8080/#) in start(self)
    105                 print("Waiting for kernel to start...")
    106             time.sleep(1)
--> 107         self._connect()
    108         return CodeBoxStatus(status="started")
    109 

[/usr/local/lib/python3.10/dist-packages/codeboxapi/box/localbox.py](https://localhost:8080/#) in _connect(self)
    131         for attempt in range(5):
    132             try:
--> 133                 self.ws = ws_connect_sync(
    134                     f"{self.ws_url}/kernels/{self.kernel_id}/channels",
    135                     open_timeout=60,

[/usr/local/lib/python3.10/dist-packages/websockets/sync/client.py](https://localhost:8080/#) in connect(uri, sock, ssl_context, server_hostname, unix, path, origin, extensions, subprotocols, additional_headers, user_agent_header, compression, open_timeout, close_timeout, max_size, logger, create_connection)
    287         )
    288         # On failure, handshake() closes the socket and raises an exception.
--> 289         connection.handshake(
    290             additional_headers,
    291             user_agent_header,

[/usr/local/lib/python3.10/dist-packages/websockets/sync/client.py](https://localhost:8080/#) in handshake(self, additional_headers, user_agent_header, timeout)
     96 
     97         if self.protocol.handshake_exc is not None:
---> 98             raise self.protocol.handshake_exc
     99 
    100     def process_event(self, event: Event) -> None:

[/usr/local/lib/python3.10/dist-packages/websockets/client.py](https://localhost:8080/#) in parse(self)
    336 
    337             try:
--> 338                 self.process_response(response)
    339             except InvalidHandshake as exc:
    340                 response._exception = exc

[/usr/local/lib/python3.10/dist-packages/websockets/client.py](https://localhost:8080/#) in process_response(self, response)
    150 
    151         if response.status_code != 101:
--> 152             raise InvalidStatus(response)
    153 
    154         headers = response.headers

InvalidStatus: server rejected WebSocket connection: HTTP 404

I don't know why, but I can't connect to the server. I found that kernel can't start.
Anyone knows how to solve this problem?

Any help is appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions