Back

Errors on Fresh install

  • 0
  • Self Hosted
Alex Bourg
6 Apr, 2024, 06:43

Hi, I am new to appwrite, I tried to install it on multiple servers, including self-hosted, and digitalocean droplet.. after each fresh install, the docker container keeps generating those 2 errors continuosly:

Error 1:

TypeScript
appwrite  | [Error] URL: /v1/realtime
appwrite  | [Error] Type: Appwrite\Extend\Exception
appwrite  | [Error] Message: The requested route was not found. Please refer to the API docs and try again.
appwrite  | [Error] File: /usr/src/code/app/controllers/general.php
appwrite  | [Error] Line: 860

Error 2:

TypeScript
appwrite  | [Error] Method: GET
appwrite  | [Error] URL: /v1/account
appwrite  | [Error] Type: Appwrite\Extend\Exception
appwrite  | [Error] Message: User (role: guests) missing scope (account)
appwrite  | [Error] File: /usr/src/code/app/controllers/shared/api.php
appwrite  | [Error] Line: 272
TL;DR
Developers facing errors on a fresh install of Appwrite behind nginx. Realtime feature not working, leading to errors and lack of automatic data updates. Realtime error may be causing the website data not to update without a page refresh. The solution is to call the account endpoint as an end user with a session, not just an API key. A manual test of the endpoint received a 401 code due to a missing scope. Further troubleshooting requires investigating the Appwrite installation method and configuration.
Alex Bourg
6 Apr, 2024, 13:59

I tried to manually test this endpoint using this request

TypeScript
curl -H "X-Appwrite-Project: your_project_id" \
     -H "X-Appwrite-Key: your_api_key" \
     -H "Content-Type: application/json" \
     -X GET "http://cms.itexpertnow.com/v1/account"

and got this response:

TypeScript
{
    "message": "app.6610481f003bf0704275@service.cms.itexpertnow.com (role: applications) missing scope (account)",
    "code": 401,
    "type": "general_unauthorized_scope",
    "version": "1.5.4"
}
Alex Bourg
6 Apr, 2024, 19:08

also the data on the website is not automatically updated, I have to refresh the page to get the new data... is this because of the realtime error? how to troubleshoot please

Steven
7 Apr, 2024, 04:52

This is happening because realtime isn't working. how did you install Appwrite? Do you have anything in front of Appwrite?

Steven
7 Apr, 2024, 04:52

error 2 is expected if you don't have a session

Steven
7 Apr, 2024, 04:52

you can't call the account endpoint with an api key like that. it's meant to be called as an end user with a session

Alex Bourg
7 Apr, 2024, 23:04

more digging, I hope someone will be able to help... btw this issue is on fresh install...

docker logs -f appwrite

TypeScript
[Error] Method: 
[Error] URL: /v1/realtime
[Error] Type: Appwrite\Extend\Exception
[Error] Message: The requested route was not found. Please refer to the API docs and try again.
[Error] File: /usr/src/code/app/controllers/general.php
[Error] Line: 860

Browser console log:

TypeScript
sdk.alo1Ck00.js:1  WebSocket connection to 'wss://cms.itexpertnow.com/v1/realtime?project=console&channels%5B%5D=project&channels%5B%5D=console' failed: 
createSocket @ sdk.alo1Ck00.js:1
(anonymous) @ sdk.alo1Ck00.js:1
r @ 0.DelvZ7a0.js:33
0.DelvZ7a0.js:15  Realtime got disconnected. Reconnect will be attempted in 1 seconds. 
(anonymous) @ 0.DelvZ7a0.js:15
(anonymous) @ sdk.alo1Ck00.js:1
r @ 0.DelvZ7a0.js:33
Steven
7 Apr, 2024, 23:10

Again... How did you install Appwrite and do you have anything in front of Appwrite?

Alex Bourg
8 Apr, 2024, 01:13

Appwrite is selfhosted and behind nginx reverse proxy:

Current config:

TypeScript
location ~ ^/.* {
    proxy_pass http://0.0.0.0:32790;
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Upgrade $http_upgrade;
    proxy_http_version 1.1;
}
Alex Bourg
8 Apr, 2024, 01:14
ideclon
8 Apr, 2024, 01:28

How did you install Appwrite?

Steven
8 Apr, 2024, 01:29

And did you do something to the traefik container?

ideclon
8 Apr, 2024, 01:29

That’s because it seems Realtime isn’t running, for some reason. If you tell us how you installed Appwrite, we could start trying to figure out why that is

Alex Bourg
8 Apr, 2024, 13:00

I am running selfhosted appwrite behind nginx:

TypeScript
$:/home/appwrite# docker port appwrite-traefik
80/tcp -> 0.0.0.0:32080
80/tcp -> [::]:32080
443/tcp -> 0.0.0.0:32443
443/tcp -> [::]:32443

working: wss://cms.itexpertnow.com:32443/v1/realtime?project=console&channels%5B%5D=project&channels%5B%5D=console

not working: wss://cms.itexpertnow.com/v1/realtime?project=console&channels%5B%5D=project&channels%5B%5D=console

Nginx config:

TypeScript
location ~ ^/.* {
    proxy_pass http://0.0.0.0:32790;
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Upgrade $http_upgrade;
    proxy_http_version 1.1;
}

location /v1/realtime {
    proxy_pass http://0.0.0.0:32443;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 600s;
    proxy_send_timeout 600s;
}

docker config:

TypeScript
  traefik:
    image: traefik:2.11
    container_name: appwrite-traefik
    <<: *x-logging
    command:
      - --providers.file.directory=/storage/config
      - --providers.file.watch=true
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.constraints=Label(`traefik.constraint-label-stack`,`appwrite`)
      - --entrypoints.appwrite_web.address=:80
      - --entrypoints.appwrite_websecure.address=:443
    restart: unless-stopped
    ports:
      - 32080:80
      - 32443:443
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more