Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Unable to start Upload Session #69

Open
reapermarv opened this issue May 23, 2022 · 5 comments
Open

Unable to start Upload Session #69

reapermarv opened this issue May 23, 2022 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@reapermarv
Copy link

Service Versions (please complete the following information):
Paste the output of ./server.sh version. For example:

             Container                          Repository                 Tag         Image Id       Size
------------------------------------------------------------------------------------------------------------
api-gateway-standalone                standardnotes/api-gateway         1.37.0              c2570ab8bf6b        836MB
auth-standalone                       standardnotes/auth                1.43.0              c92cd09c8a36        894MB
auth-worker-standalone                standardnotes/auth                1.43.0              c92cd09c8a36        894MB
cache-standalone                      redis                             6.0-alpine          131bc9ee328c        31.4MB
db-standalone                         mysql                             5.6                 dd3b2a5dcb48        303MB
syncing-server-js-standalone          standardnotes/syncing-server-js   1.52.0              5ec2d274a36e        1.01GB
syncing-server-js-worker-standalone   standardnotes/syncing-server-js   1.52.0              5ec2d274a36e        1.01GB

Describe the issue
After setting up the instance and being able to create notes and so on, I tried to attach a file to a note but ran into an error. I've given the rights via the sql command so the user is allowed to perform the action (paid plan).

The Errors in the application:
"Unable to start upload session"
"There was an error while uploading the file"

The server logs give the following errors:
auth-standalone | query: SELECT setting.uuid AS setting_uuid, setting.name AS setting_name, setting.value AS setting_value, setting.server_encryption_version AS setting_server_encryption_version, setting.created_at AS setting_created_at, setting.updated_at AS setting_updated_at, setting.sensitive AS setting_sensitive, setting.user_subscription_uuid AS setting_user_subscription_uuid FROM subscription_settings setting WHERE setting.name = ? AND setting.user_subscription_uuid = ? ORDER BY updated_at DESC LIMIT 1 -- PARAMETERS: ["FILE_UPLOAD_BYTES_LIMIT","9204ade1-da9b-11ec-834a-0242ac120002"]
auth-standalone | {"message":"Error: secretOrPrivateKey must have a value\n at module.exports (/var/www/node_modules/jsonwebtoken/sign.js:107:20)\n at TokenEncoder.encodeExpirableToken (/var/www/node_modules/@standardnotes/auth/dist/Domain/Encoder/TokenEncoder.js:10:40)\n at CreateValetToken.execute (/var/www/dist/src/Domain/UseCase/CreateValetToken/CreateValetToken.js:82:46)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async ValetTokenController.create (/var/www/dist/src/Controller/ValetTokenController.js:36:40)","level":"error"}
api-gateway-standalone | {"level":"error","message":"Could not pass the request to http://auth:3000/valet-tokens on underlying service: undefined"}

I've followed the wiki and used the server.sh script to set everything up, the only thing I've changed were the secrets and the nginx config for the ssl certificates.

@reapermarv reapermarv added the help wanted Extra attention is needed label May 23, 2022
@moughxyz
Copy link
Member

Files are not yet supported in the standalone config, but this is something we have on our high priority todo.

@BobWs
Copy link

BobWs commented Jun 1, 2022

Will this also work/ be available for the self hosting version?

Because I’m also not able to upload files, but the upload button is present in the desktop app and in the mobile apps

@Wadera
Copy link

Wadera commented Oct 5, 2022

I think this can be closed as resolved.

There is clear section about get this configured in documentation:
https://docs.standardnotes.com/self-hosting

I've got it working! 🙂
If anyone will looks for solution - you need to get separate subdomain set in .env and ./docker/.env files:

root@docker:/opt/standalone# grep FILES .env
EXPOSED_FILES_PORT=3125
FILES_SERVER_URL=https://notefile.myserver.tdl/

root@docker:/opt/standalone# grep FILE docker/.env
FILES_SERVER_URL="https://notefile.myserver.tdl/"

Then set standard proxy for your domain and port 3125 port 😉
It looking great. I'm looking ahead to see it working as quick paste images to markdown notes with auto uploads and display into notes!

Of Course - you need to activate subscription for your account and set quota size as explain in docs:

https://docs.standardnotes.com/self-hosting/subscriptions

./server.sh create-subscription EMAIL@ADDR

and:
https://docs.standardnotes.com/self-hosting/file-uploads

INSERT INTO subscription_settings(uuid, name, value, created_at, updated_at, user_subscription_uuid) VALUES (UUID(), "FILE_UPLOAD_BYTES_LIMIT", 10737418240, FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), FLOOR(UNIX_TIMESTAMP(NOW(6))*1000000), (SELECT us.uuid FROM user_subscriptions us INNER JOIN users u ON us.user_uuid=u.uuid WHERE u.email="EMAIL@ADDR"));

But please be aware of: #83

@NODRT
Copy link

NODRT commented Jan 5, 2023

One thing I didn't see mentioned here that tripped me up is how to set this up while using a reverse proxy. I finally got it working and wanted to share the magic ingredient.

The Standard Notes Files Server needs its own entry in your reverse proxy conf file. I gave mine its own subdomain, so I have these domains:

Standard Notes domain: https://snotes.MYDOMAIN.com
Standard Notes Files domain: https://snotesfiles.MYDOMAIN.com

In case it helps anyone, this is my nginx reverse proxy code. Notice the entry for notes and the entry for files. Also, everything pertaining to HTTPS was written there by Certbot, so if you're copying this code, remove the lines of code (or chunks of code) that say "managed by Certbot".

server{
    if ($host = notes.MYDOMAIN.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


  server_name snotes.MYDOMAIN.com;

  location ~ {
    proxy_pass_header Authorization;
    proxy_pass http://192.168.1.16:3000;

    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 Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_http_version 1.1;

    #proxy_set_header Connection "";
    proxy_buffering off;
    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;

  }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/snotes.MYDOMAIN.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/snotes.MYDOMAIN.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server{
    if ($host = notes.MYDOMAIN.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

  server_name snotesfiles.MYDOMAIN.com;

  location ~ {
    proxy_pass_header Authorization;
    proxy_pass http://192.168.1.16:3125;

    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 Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_http_version 1.1;

    #proxy_set_header Connection "";
    proxy_buffering off;
    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
  }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/snotesfiles.MYDOMAIN.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/snotesfiles.MYDOMAIN.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

So, that was step one. Then, the .env files needed to reflect this.

Update the self-hosted/.env file and the standalone/.env file (I'm not sure why I have it in two places. Is one from my previous failed installation? Maybe. Maybe not.):
FILES_SERVER_URL=https://snotesfiles.MYDOMAIN.com

Do NOT include the port (3125) after the domain name in this config file. Doing so will cause your reverse proxy to send the request to the wrong place and it will fail. Just use the subdomain and let the reverse proxy send it to port 3125.

@BobWs
Copy link

BobWs commented Jan 20, 2023

Thanks for sharing!
Do you have a example how to do this with NPM Nginx-Proxy-Manager?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants