ONLYOFFICE / DocumentServer

ONLYOFFICE Docs is a free collaborative online office suite comprising viewers and editors for texts, spreadsheets and presentations, forms and PDF, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
https://www.onlyoffice.com
GNU Affero General Public License v3.0
4.89k stars 1.09k forks source link

Connection refused in test example #1819

Closed Entmatix closed 2 years ago

Entmatix commented 2 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior? Eternal "Loading document/spreadsheet/..."

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

  1. Install documentserver with docker.
  2. Start container.
  3. Open webpage for documentserver.
  4. Execute command from webpage to start example service.
  5. Click on "Go to example test" on webpage.
  6. In "Create new" section click on "Document".

What is the expected behavior? Open empty document/spreadsheet/.. for writing/edition/whatever.

Did this work in previous versions of DocumentServer? Don't know.

DocumentServer version: Latest from hub.docker.com

Operating System: Slackware 15.0

Browser version: Safari 15.5, Firefox 102.0

Docker compose

services:
  app:
    image: onlyoffice/documentserver:latest
    container_name: documentserver
    restart: always
    ports:
      - "50085:80"
    volumes:
      - /mnt/media/docker/containers/documentserver/log:/var/log/onlyoffice
      - /mnt/media/docker/containers/documentserver/data:/var/www/onlyoffice/Data

networks:
  default:
    name: dockerprv0

Log

documentserver  | 2022/07/07 05:32:38 [error] 6451#6451: *8 connect() failed (111: Connection refused) while connecting to upstrea
m, client: 192.168.77.28, server: , request: "GET /example/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "ds.mydomain.xyz",
 referrer: "https://ds.mydomain.xyz/welcome/"
documentserver  | 2022/07/07 05:32:38 [error] 6451#6451: *8 connect() failed (111: Connection refused) while connecting to upstrea
m, client: 192.168.77.28, server: , request: "GET /example/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "ds.mydomain.xyz",
 referrer: "ht
tps://ds.mydomain.xyz/welcome/"
documentserver  | 2022/07/07 13:06:15 [error] 6429#6429: *3 connect() failed (111: Connection refused) while connecting to upstrea
m, client: 192.168.77.28, server: , request: "GET /example/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "ds.mydomain.xyz",
 referrer: "https://ds.mydomain.xyz/welcome/"
documentserver  | 2022/07/07 13:06:15 [error] 6429#6429: *3 connect() failed (111: Connection refused) while connecting to upstrea
m, client: 192.168.77.28, server: , request: "GET /example/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "ds.mydomain.xyz",
 referrer: "https://ds.mydomain.xyz/welcome/"
ShockwaveNN commented 2 years ago

Eternal "Loading document/spreadsheet/..."

I think this may be a problem with you system firewall, try to disable it and recheck

I don't know what is firewall on Slackware, but same problem happens then Ubuntu's ufw is enabled

Entmatix commented 2 years ago

I use nftables and a dozen docker containers in same network (dockerprv0). None of them has this issue. Only documentserver. With nftables tables flushed same problem appears. So I don't see firewall as a culprit.

BTW as far as documentserver address/port is the same for everything one can do with it from webui, if webpage for service works and test example page works I assume everything should work. Am I wrong?

ShockwaveNN commented 2 years ago

Another idea -

Do you accessed test example via 127.0.0.1 ip? you should use your local network ip (for example 192.168.1.238 for me), because 127.0.0.1 on your host (in which you've opened browser) and 127.0.0.1 inside docker container is different

Entmatix commented 2 years ago

I access test example via domain name (you can see it in log - ds.mydomain.xyz). Documentserver container is behind a reverse proxy (NPM) on the same server. I'm unable to do it locally bc my server is headless. I tried to do it with ssh port forwarding

ssh -N -L 9090:localhost:50085

In this case I don't see "Loading ..." part, but almost instantly get error https://0x0.st/oQUg.png

Log:

documentserver  | ==> /var/log/onlyoffice/documentserver/docservice/out.log <==
documentserver  | [2022-07-08T09:30:39.787] [ERROR] nodeJS - postData error: docId = 172.33.0.1http___localhost_9090_example_files_172.33.0.1_new.docx1657272633675;url = http://localhost:9090/example/track?filename=new.docx&useraddress=172.33.0.1;data = {"key":"172.33.0.1http___localhost_9090_example_files_172.33.0.1_new.docx1657272633675","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}]}
documentserver  | Error: connect ECONNREFUSED 127.0.0.1:9090
documentserver  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/converter/out.log <==
documentserver  | [2022-07-08T09:30:39.794] [ERROR] nodeJS - error downloadFile:url=http://localhost:9090/example/download?fileName=new.docx&useraddress=172.33.0.1;attempt=1;code:ECONNREFUSED;connect:undefined;(id=172.33.0.1http___localhost_9090_example_files_172.33.0.1_new.docx1657272633675)
documentserver  | Error: connect ECONNREFUSED 127.0.0.1:9090
documentserver  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
documentserver  | [2022-07-08T09:30:40.797] [ERROR] nodeJS - error downloadFile:url=http://localhost:9090/example/download?fileName=new.docx&useraddress=172.33.0.1;attempt=2;code:ECONNREFUSED;connect:undefined;(id=172.33.0.1http___localhost_9090_example_files_172.33.0.1_new.docx1657272633675)
documentserver  | Error: connect ECONNREFUSED 127.0.0.1:9090
documentserver  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
documentserver  | [2022-07-08T09:30:41.799] [ERROR] nodeJS - error downloadFile:url=http://localhost:9090/example/download?fileName=new.docx&useraddress=172.33.0.1;attempt=3;code:ECONNREFUSED;connect:undefined;(id=172.33.0.1http___localhost_9090_example_files_172.33.0.1_new.docx1657272633675)
documentserver  | Error: connect ECONNREFUSED 127.0.0.1:9090
documentserver  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
ShockwaveNN commented 2 years ago

Documentserver container is behind a reverse proxy (NPM) on the same server

I think it's the reason, something is wrong with proxiyng

In this case I don't see "Loading ..." part, but almost instantly get error

Yep, this is error happens then you use localhost to open docs

Entmatix commented 2 years ago

I think it's the reason, something is wrong with proxiyng

Could be, but... As I said I have a dozen of docker services in the same situation. Every one of them works fine. I double checked nginx options for documentserver and found nothing suspicious. I even rewrited docker-compose to run another a bit similar service (cryptpad) with exactly same setup of NPM and docker (I only added a couple new strings for mounting volumes). Everything works with cryptpad. Have no idea what's the root of this problem... I really like onlyoffice and want to integrate it into my nextcloud server.

ShockwaveNN commented 2 years ago

You can try to setup DocumentServer without this reverse proxy to check that it is not the reason and if it will fail to work without it - we can try to generate some new ideas

Entmatix commented 2 years ago

Good idea. Gonna try it soon.

Entmatix commented 2 years ago

With edited docker-compose file to run documentserver in host network and without proxy:

services:
  app:
    image: onlyoffice/documentserver:latest
    container_name: documentserver
    restart: always
    volumes:
      - /mnt/media/docker/containers/documentserver/log:/var/log/onlyoffice
      - /mnt/media/docker/containers/documentserver/data:/var/www/onlyoffice/Data
    network_mode: host

I get

documentserver  | psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:4: NOTICE:  table "doc_callbacks" does not exist, skipping
documentserver  | psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:9: NOTICE:  function merge_db(pg_catalog.varchar,int2,int8,pg_catalog.timestamp,pg_catalog.varchar,int8,int8) does not exist, skipping
documentserver  | psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:10: NOTICE:  function merge_db(pg_catalog.varchar,int2,int4,pg_catalog.timestamp,pg_catalog.varchar,int4,int4) does not exist, skipping
documentserver  | Starting supervisor: supervisord.
documentserver  |  * Starting periodic command scheduler cron
documentserver  |    ...done.
documentserver  |  * Starting nginx nginx
documentserver  |    ...fail!
documentserver  | ==> /var/log/onlyoffice/documentserver/converter/err.log <==
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/converter/out.log <==
documentserver  | [2022-07-08T10:39:45.455] [WARN] nodeJS - update cluster with 1 workers
documentserver  | [2022-07-08T10:39:45.461] [WARN] nodeJS - worker 930 started.
documentserver  | [2022-07-08T10:39:45.463] [WARN] nodeJS - update cluster with 1 workers
documentserver  | [2022-07-08T10:40:24.274] [WARN] nodeJS - update cluster with 1 workers
documentserver  | [2022-07-08T10:40:24.280] [WARN] nodeJS - worker 1037 started.
documentserver  | [2022-07-08T10:40:24.282] [WARN] nodeJS - update cluster with 1 workers
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/docservice/err.log <==
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/docservice/out.log <==
documentserver  | [2022-07-08T10:39:45.878] [WARN] nodeJS - Express server starting...
documentserver  | [2022-07-08T10:39:45.879] [WARN] nodeJS - Set services.CoAuthoring.token.enable.browser, services.CoAuthoring.token.enable.request.inbox, services.CoAuthoring.token.enable.request.outbox in the Document Server config to prevent an unauthorized access to your documents and the substitution of important parameters in ONLYOFFICE Document Server requests.
documentserver  | [2022-07-08T10:39:45.880] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins, you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability
documentserver  | [2022-07-08T10:39:45.957] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 7.1.1. Build: 23
documentserver  | [2022-07-08T10:40:23.025] [WARN] nodeJS - Express server starting...
documentserver  | [2022-07-08T10:40:23.026] [WARN] nodeJS - Set services.CoAuthoring.token.enable.browser, services.CoAuthoring.token.enable.request.inbox, services.CoAuthoring.token.enable.request.outbox in the Document Server config to prevent an unauthorized access to your documents and the substitution of important parameters in ONLYOFFICE Document Server requests.
documentserver  | [2022-07-08T10:40:23.026] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins, you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability
documentserver  | [2022-07-08T10:40:23.047] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 7.1.1. Build: 23
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/metrics/err.log <==
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/metrics/out.log <==
documentserver  | 8 Jul 10:39:45 - [894] reading config file: ./config/config.js
documentserver  | 8 Jul 10:39:45 - server is up INFO
documentserver  |
documentserver  | ==> /var/log/onlyoffice/documentserver/nginx.error.log <==

nginx.err.log and err.log are empty. Container is shown as running, but it's unreachable both from localhost and lan:

curl -I localhost:5000
curl: (7) Failed to connect to localhost port 5000 after 0 ms: Connection refused
curl -I 192.168.77.28:5000
curl: (7) Failed to connect to 192.168.77.28 port 5000 after 0 ms: Connection refused
ShockwaveNN commented 2 years ago

@Entmatix I'm not sure about netwrork_mode: host since I've never used it

Maybe check simplest run option via

docker run -itd -p 5000:80 onlyoffice/documentserver
Entmatix commented 2 years ago

@ShockwaveNN unfortunately it doesn't work too. The command you suggested simply using docker0 interface (bridge). Overall it's no different from my dockerprv0 except I didn't set it in nftables. I allowed docker0 interface and it's 172.17.0.0/24 subnet in firewall and tried it. Got exactly the same errors when was accessing via localhost and lan ip.

docker run -itd -p 50085:80 --name onlyoffice onlyoffice/documentserver
docker network inspect bridge | grep "Containers" -A 20
        "Containers": {
            "3d732d6bc691873f249a37e41df10ebdcae2a66e7d6ecf3e13eff44aba864ae7": {
                "Name": "onlyoffice",
                "EndpointID": "8ade7ef210b39feb1fce73a16b7cbdd4876894fc29c4df49a5ec9e284f0e9bcc",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]
==> /var/log/onlyoffice/documentserver/converter/out.log <==
[2022-07-08T16:27:08.179] [ERROR] nodeJS - error downloadFile:url=http://192.168.77.28:50085/example/download?fileName=new.docx&useraddress=192.168.77.10;attempt=1;code:ETIMEDOUT;connect:undefined;(id=192.168.77.10http___192.168.77.28_50085_example_files_192.168.77.10_new.docx1657297377132)
Error: Error: whole request cycle timeout
    at raiseError (/snapshot/server/build/server/Common/sources/utils.js)
    at Timeout._onTimeout (/snapshot/server/build/server/Common/sources/utils.js)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)

[2022-07-08T16:22:38.657] [ERROR] nodeJS - error downloadFile:url=http://localhost:9090/example/download?fileName=new.docx&useraddress=172.17.0.1;attempt=2;code:ECONNREFUSED;connect:undefined;(id=172.17.0.1http___localhost_9090_example_files_172.17.0.1_new.docx1657297356846)
Error: connect ECONNREFUSED 127.0.0.1:9090
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
[2022-07-08T16:22:39.660] [ERROR] nodeJS - error downloadFile:url=http://localhost:9090/example/download?fileName=new.docx&useraddress=172.17.0.1;attempt=3;code:ECONNREFUSED;connect:undefined;(id=172.17.0.1http___localhost_9090_example_files_172.17.0.1_new.docx1657297356846)
Error: connect ECONNREFUSED 127.0.0.1:9090
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
ShockwaveNN commented 2 years ago

[2022-07-08T16:27:08.179] [ERROR] nodeJS - error downloadFile:url=http://192.168.77.28:50085/example/download?fileName=new.docx&useraddress=192.168.77.10;attempt=1;code:ETIMEDOUT;connect:undefined;(id=192.168.77.10http___192.168.77.28_50085_example_files_192.168.77.10_new.docx1657297377132)

This is not right, I think you can try to connect to container and try to run

curl http://192.168.77.28:50085/example/download?fileName=new.docx

Seems that it will raise connection error and this is not right, I'm not very good at docker network so I don't think I can help you, but I can assure those errors are very rare on default setups so I think it should be something to do with your custom network setups

Entmatix commented 2 years ago

My network setup could be an issue, but I can't discard the fact all other containers work fine in this setup.

ce0f3cb91324  adguard              running  Up  29  hours
47ad9e116e28  gitea                running  Up  29  hours
9baf8c307b9e  homer                running  Up  29  hours  (healthy)
b31153d1db03  kavita               running  Up  29  hours  (healthy)
b3a903e9064f  kiwix                running  Up  29  hours
5407d609122a  miniflux-db          running  Up  29  hours  (healthy)
a86d4efa4f58  miniflux             running  Up  29  hours
0ed7556ed39c  netdata              running  Up  29  hours  (healthy)
cc431ef39df7  nextcloud-db         running  Up  29  hours
7fdf8ad5b11e  nextcloud            running  Up  29  hours
3071eff73b75  nginx-proxy-manager  running  Up  29  hours
3d732d6bc691  onlyoffice           running  Up  2   hours
8ff46c60a3b4  plex                 running  Up  29  hours  (healthy)
c4af3519efd7  portainer            running  Up  29  hours
baea26432c1f  rustdesk-hbbr        running  Up  29  hours
22f1124e4e97  rustdesk-hbbs        running  Up  29  hours
1b7cd63aa220  transmission         running  Up  29  hours
8d25cf3d8e39  vaultwarden          running  Up  29  hours  (healthy)
2f3edf21acfc  wallabag             running  Up  29  hours
3623bb21f3ce  whoogle              running  Up  29  hours  (healthy)

It's interesting...

root@3d732d6bc691:/# ping 192.168.77.28 -c 4
PING 192.168.77.28 (192.168.77.28) 56(84) bytes of data.
64 bytes from 192.168.77.28: icmp_seq=1 ttl=64 time=0.040 ms
64 bytes from 192.168.77.28: icmp_seq=2 ttl=64 time=0.037 ms
64 bytes from 192.168.77.28: icmp_seq=3 ttl=64 time=0.037 ms
64 bytes from 192.168.77.28: icmp_seq=4 ttl=64 time=0.037 ms

--- 192.168.77.28 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3083ms
rtt min/avg/max/mdev = 0.037/0.037/0.040/0.001 ms
root@3d732d6bc691:/# curl 192.168.77.28:50085
curl: (28) Failed to connect to 192.168.77.28 port 50085: Connection timed out
root@3d732d6bc691:/# curl http://192.168.77.28:50085/example/download?fileName=new.docx
curl: (28) Failed to connect to 192.168.77.28 port 50085: Connection timed out

First time I see container from which I can ping address, but can't curl. Any ideas?

ShockwaveNN commented 2 years ago

My network setup could be an issue, but I can't discard the fact all other containers work fine in this setup.

I think it's just our setup is little bit more complicated that most containers )

First time I see container from which I can ping address, but can't curl. Any ideas?

Try to curl not 50085 but 80 port

Inside container, it's using 80 port

Entmatix commented 2 years ago

Actually, I can curl by container name from another container that is in the same network (nextcloud):

root@7fdf8ad5b11e:/var/www/html# curl -I documentserver
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Fri, 08 Jul 2022 18:49:53 GMT
Content-Type: text/html
Content-Length: 138
Connection: keep-alive
Location: http://documentserver/welcome/

Try to curl not 50085 but 80 port

Yeah, but 192.168.77.28 is lan ip. According to you recommendation about vanilla command to start documentserver, I pushed port 50085, not 5000 or 80. Here is a curl with localhost inside documentserver container where port 80 is reserved for nginx of the container:

curl -I localhost:80
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Fri, 08 Jul 2022 18:50:37 GMT
Content-Type: text/html
Content-Length: 138
Connection: keep-alive
Location: http://localhost/welcome/
ShockwaveNN commented 2 years ago

I'm out idea, I'm almost sure that it has something to do with docker networking, but I have no idea how to resolve it

Entmatix commented 2 years ago

Anyway thanks for trying to help, @ShockwaveNN. Gonna dig it later.

ShockwaveNN commented 2 years ago

I'll close this issue since there is no response for over a month. Feel free to reopen or create a new one if got any new info

yokesh22 commented 1 year ago

Another idea -

Do you accessed test example via 127.0.0.1 ip? you should use your local network ip (for example 192.168.1.238 for me), because 127.0.0.1 on your host (in which you've opened browser) and 127.0.0.1 inside docker container is different

This works for me !!

bohwaz commented 2 months ago

This is a issue with OnlyOffice on Docker, usually when set up on localhost using a different port than 80. It is not using the correct port internally when the docker container is started using a different port than 80.

Using the local network IP is not a fix, it's just getting around the bug. And it won't work when you don't have a network IP (eg. when you are offline).

This bug bites me every time.