Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server rejected WebSocket connection: HTTP 404 #152

Open
N4RLY opened this issue Mar 3, 2024 · 2 comments
Open

Server rejected WebSocket connection: HTTP 404 #152

N4RLY opened this issue Mar 3, 2024 · 2 comments

Comments

@N4RLY
Copy link

N4RLY commented Mar 3, 2024

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 :)

@okoliechykwuka
Copy link

okoliechykwuka commented Mar 11, 2024

I am having same error

websockets.exceptions.InvalidStatusCode

websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404

Someone should please help

@shroominic please help

@jonah-ramponi
Copy link

I resolved this by installing latest versions of the following:

jupyter-kernel-gateway==3.0.1    
jupyter-client==8.6.1   
notebook==7.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants