ItzCrazyKns / Perplexica

Perplexica is an AI-powered search engine. It is an Open source alternative to Perplexity AI
MIT License
13.03k stars 1.22k forks source link

WebSocket Connection Failure in DevTools Console #14

Closed arunkumarakvr closed 2 months ago

arunkumarakvr commented 4 months ago

Title: WebSocket Connection Failure in DevTools Console

Body:

Issue Description

When attempting to establish a WebSocket connection, the DevTools console displays the following error message:

page-c1977eaac74b29da.js:1 WebSocket connection to 'ws://127.0.0.1:3001/' failed:

Steps to Reproduce

  1. Open the DevTools console in the browser.
  2. Attempt to connect to the WebSocket server at ws://127.0.0.1:3001/.
  3. Observe the error message.

Expected Behavior

The WebSocket connection should be established successfully without any errors.

Actual Behavior

The connection fails, and the DevTools console logs an error message indicating the failure.

Possible Solutions

Additional Context

Please provide any additional information that might be helpful in resolving this issue, such as server logs, network configuration, or browser version.

ItzCrazyKns commented 4 months ago

Hi, I understand the problem and I would recommend you to follow the solutions you shared. Make sure the API server is accessible from the browser at http://127.0.0.1:3001. If not please check the configuration, firewall errors or network issues

arunkumarakvr commented 4 months ago

@ItzCrazyKns It seems that the WebSocket server is not defined in any provided Dockerfiles or the docker-compose.yaml file. So then how do I start or initiate and handle the WebSocket server here? Due to this, Am I getting the different console errors like page-2abbb79b5568719c.js:1 WebSocket is already in CLOSING or CLOSED state? Help fix these WebSocket problems.

arunkumarakvr commented 4 months ago

Also, how do I make sure the API server is accessible from the browser at http://127.0.0.1:3001/?

Hi, I understand the problem and I would recommend you to follow the solutions you shared. Make sure the API server is accessible from the browser at http://127.0.0.1:3001. If not please check the configuration, firewall errors or network issues @ItzCrazyKns Also, how do I make sure the API server is accessible from the browser at http://127.0.0.1:3001/?

arunkumarakvr commented 4 months ago

@ItzCrazyKns From _VM_UbuntuBash `:~/Perplexica$ docker compose logs` of perplexica-backend

...
perplexica-perplexica-backend-1  | yarn run v1.22.19
perplexica-perplexica-backend-1   | $ node dist/app.js
perplexica-perplexica-backend-1   | WebSocket server started on port 3001
perplexica-perplexica-frontend-1  |  ✓ Ready in 951ms
perplexica-perplexica-backend-1   | (node:28) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
...
perplexica-perplexica-backend-1   | (Use `node --trace-deprecation ...` to show where the warning was created)
perplexica-perplexica-backend-1   | API server started on port 3001
perplexica-perplexica-backend-1   | Connection closed
perplexica-perplexica-backend-1   | Connection closed
perplexica-perplexica-backend-1   | Connection closed
perplexica-perplexica-backend-1   | Connection closed
perplexica-perplexica-backend-1   | Connection closed
...
ItzCrazyKns commented 4 months ago

Also, how do I make sure the API server is accessible from the browser at http://127.0.0.1:3001/?

Hi, I understand the problem and I would recommend you to follow the solutions you shared. Make sure the API server is accessible from the browser at http://127.0.0.1:3001. If not please check the configuration, firewall errors or network issues @ItzCrazyKns Also, how do I make sure the API server is accessible from the browser at http://127.0.0.1:3001/?

Just visit this URL http://127.0.0.1:3001/api and see if something appears there.

ItzCrazyKns commented 4 months ago

@ItzCrazyKns It seems that the WebSocket server is not defined in any provided Dockerfiles or the docker-compose.yaml file. So then how do I start or initiate and handle the WebSocket server here? Due to this, Am I getting the different console errors like page-2abbb79b5568719c.js:1 WebSocket is already in CLOSING or CLOSED state? Help fix these WebSocket problems.

The WebSocket part is handled by the server. It is defined at src/websocket/index.ts

ItzCrazyKns commented 4 months ago

Also if you're making use of Ollama, make sure to use the complete model name in the config.toml file (like llama2:latest), or you can download the latest version of Perplexica, it has a settings page from where you can edit it without having to configure the config file manually.

arunkumarakvr commented 4 months ago

@ItzCrazyKns In the config.toml case, there are still errors particularly related to Perplexica Backend docker container : WebSocket/API servers

Error loading Ollama models: TypeError: Fetch Failed Connection Closed

despite the API and Ollama seems ok as follows. http://127.0.0.1:3001/api { "status": "ok" }
... localhost:11434 Ollama is running

In the .env case, it turns out that it becomes like WebSocket Failed at some point after within a few minutes of starting the docker containers but no answer generation at all anytime. Error Connection Refused. Help fix these major WebSocket issues everywhere particularly Ollama and also non-ollama case.

ItzCrazyKns commented 4 months ago

Change your Ollama URL to http://host.docker.internal:11434, Ollama should work fine then.

noah003 commented 4 months ago

Change your Ollama URL to http://host.docker.internal:11434, Ollama should work fine then.

doesn't work for me

ItzCrazyKns commented 4 months ago

Change your Ollama URL to http://host.docker.internal:11434, Ollama should work fine then.

doesn't work for me

Could you please provide more information?

Swiftyos commented 4 months ago

I'm trying to run this on a MacBook, using openai as the provider.

I keep getting connection closed in the logs with no other error message. When entering a search the ui changes to the search result page, but nothing else happens.

No messages in the logs and I can't find anywhere were there is a record of a request being sent to the backend

Swiftyos commented 4 months ago

I'm trying to run this on a MacBook, using openai as the provider.

I keep getting connection closed in the logs with no other error message. When entering a search the ui changes to the search result page, but nothing else happens.

No messages in the logs and I can't find anywhere were there is a record of a request being sent to the backend

My issue was due to having another service using port 8080 so the SEARXNG server could not bind to the port.

We need more logging messages to make it easer to debug though @ItzCrazyKns

Shiyinq commented 4 months ago

same problem

image

my config

image

docker compose

image

api

image
ItzCrazyKns commented 4 months ago

Could you show the backend logs? If it says something like connected failed while fetching Ollama models its probably because it could not connect to Ollama. I am working on a patch that would fix it.

ItzCrazyKns commented 3 months ago

Hi @arunkumarakvr is this issue resolved or your still need support? If you don't respond within the next 24 hours we'll close this issue as completed.

arunkumarakvr commented 3 months ago

@ItzCrazyKns Could you please show or share with us how you've resolved or fixed this issue particularly? Anything else is done to fix this WebSocket issue particularly, as I still don't know how to fix this issue or what caused this in the first place. And it also seems that many still have been experiencing this unresolved WebSocket issue. I think you should take some action for resolving this to fix it. Best.