zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
26.88k stars 1.88k forks source link

Problem with syncing from desktop in server #2557

Closed Magic-King closed 2 years ago

Magic-King commented 2 years ago

Trilium Version

0.49.5

What operating system are you using?

Ubuntu

What is your setup?

Local + server sync

Operating System Version

local: windows 10 21H1; Server: Ubuntu 20.04 LTS; docker Version:20.10.6

Description

When I want to sync from desktop in new server, I meet this

Sync server handshake failed, error: Request to GET http://[trilium-server]/api/setup/status failed, error: 500 Internal Server Error

and in server the logs show below:

$ sudo docker run -t -i -d -p 127.0.0.1:10080:8080 -v ~/trilium-data:/home/node/trilium-data zadam/trilium:0.49.5
image id
$ sudo docker logs xxxx
DB size: 4 KB
DB not initialized, please visit setup page - http://[your-server-host]:8080 to see instructions on how to initialize Trilium.
App HTTP server starting up at port 8080
{
  "appVersion": "0.49.5",
  "dbVersion": 189,
  "syncVersion": 23,
  "buildDate": "2022-01-14T21:40:37+01:00",
  "buildRevision": "77c6c4617b634226e12ead172482fe1fe92bc360",
  "dataDirectory": "/home/node/trilium-data",
  "clipperProtocolVersion": "1.0"
}
CPU model: Intel(R) Xeon(R) CPU E5-26xx v4, logical cores: 1 freq: 2394 Mhz
Listening on port 8080

nginx configure:

         server{
                listen 80;
                server_name     [trilium-server];
                location / {
                        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_pass http://127.0.0.1:10080/; #change it to your IP and port
                        proxy_read_timeout 90;
                        proxy_redirect http://127.0.0.1:10080 https://[trilium-server]; #change them based on your IP, port and domain
                }
        }

and I try to access http://[trilium-server]/api/setup/status in my chrome, and it return me {"isInitialized":false,"schemaExists":false,"syncVersion":23} and i think it's right.

Can you help me point out what's wrong with this?

zadam commented 2 years ago

Hi, the logs/configuration seem OK. Since it works from browser, it seems that nginx is also configured correctly.

Is it possible that there's some proxy on the client side (typically corporate proxy servers)?

Magic-King commented 2 years ago

Actually, I have system proxy with shodowsocksR, but the proxy works well with my other application.And I didn't config the proxy for trilium (leave Sync proxy server (optional) blank ) before.

And I just try to set proxy to my SSR and test sync again.(The logs are here) It seem failed again. But I don't know if this is success of sync, because there were some success request.

21:22:37.319 200 GET /api/options/user-themes with 190 bytes took 1ms
21:22:38.652 sync failed: Request to GET http://[trilium-server]/api/setup/status failed, error: 500 Internal Server Error
stack: Error: Request to GET http://[trilium-server]/api/setup/status failed, error: 500 Internal Server Error
    at generateError (\path\to\trilium\0.49.5\resources\app.asar\src\services\request.js:191:12)
    at ClientRequest.<anonymous> (\path\to\trilium\0.49.5\resources\app.asar\src\services\request.js:62:28)
    at ClientRequest.emit (node:events:394:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:621:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
    at Socket.socketOnData (node:_http_client:487:22)
    at Socket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
21:22:39.244 200 POST /api/sync/test with 133 bytes took 3ms
21:22:43.999 200 GET /api/backend-log with 61945 bytes took 1ms
21:22:47.430 200 GET /api/backend-log with 62010 bytes took 1ms
21:22:47.968 200 GET /api/backend-log with 62075 bytes took 0ms
21:22:48.204 200 GET /api/backend-log with 62140 bytes took 2ms
21:22:48.383 200 GET /api/backend-log with 62205 bytes took 0ms
zadam commented 2 years ago

Is it possible to deactivate that proxy for testing to see if it's really the cause?

But TBH I do think it's that. If that GET request works from Chrome there's no reason why it wouldn't work in Trilium, unless Trilium doesn't have the same proxy setup as Chrome.

config the proxy for trilium (leave Sync proxy server (optional) blank )

If the "proxy" in Sync options is not configured, then it will attempt to use the system proxy.

Magic-King commented 2 years ago

Thanks for answering me. I have tried to close my proxy, and the sync is sccessful(but often timeout with 7s limit). I am sure the proxy is the same, and I try another proxy app(clash), it works well with trilium. I think maybe trilium doesn't support socks5 proxy, which caused the problem happened

Magic-King commented 2 years ago

After syncing, I will try to capture the traffic to find out what caused the problem