Skip to content

Race condition in start.sh #54

@dljaime

Description

@dljaime

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

Probably not the easiest way but this is how I got here. I'm running on a raspberry pi with ssd

  1. Setup nextcloud docker (I used nginx/maria/fpm)
  2. Add HaRP
    appapi-harp:
        container_name: appapi-harp
        image: ghcr.io/nextcloud/nextcloud-appapi-harp:latest
        restart: always
        environment:
          - HP_SHARED_KEY=myspecialtestkey
          - NC_INSTANCE_URL=htp://nexcloud.url
        volumes:
           - /var/run/docker.sock:/var/run/docker.sock
           - ./certs:/certs
         secrets:
           - nextcloud-harp-shared-key
    
    secrets:
      nextcloud-harp-shared-key:
        file: ./secret_harp_shared_key.txt
    
  3. Setup daemon in nextcloud
  4. Click Check connection

Expected behaviour

Connection works

Actual behaviour

Connection times out

HaRP container logs
INFO: FRP server configuration generated at /frps.toml.
INFO: Detected /var/run/docker.sock, generating /frpc-docker.toml configuration file...
INFO: Starting Python HaProxy Agent on 127.0.0.1:8200 and 127.0.0.1:9600...
INFO: Starting FRP server on 0.0.0.0:8782...
INFO: Starting FRP client for Docker Engine...
INFO: Starting HAProxy...
2025-10-18 18:51:04.507 [I] [sub/root.go:142] start frpc service for config file [/frpc-docker.toml]
2025-10-18 18:51:04.508 [I] [client/service.go:295] try to connect to server...
[NOTICE]   (1) : Initializing new worker (37)
2025-10-18 18:51:04.612 [E] [client/service.go:280] send Login request to plugin error
2025-10-18 18:51:04.613 [W] [client/service.go:298] connect to server error: send Login request to plugin error
2025-10-18 18:51:04.614 [I] [sub/root.go:160] frpc service for config file [/frpc-docker.toml] stopped
login to the server failed: send Login request to plugin error. With loginFailExit enabled, no additional retries will be attempted
[NOTICE]   (1) : haproxy version is 3.1.2-cda631a
[WARNING]  (1) : Process 30 exited with code 1 (Exit)
[NOTICE]   (1) : Loading success.
[WARNING]  (37) : Server agents/agent1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT]    (37) : backend 'agents' has no server available!
<129>Oct 18 18:51:04 haproxy[37]: Server agents/agent1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
<128>Oct 18 18:51:04 haproxy[37]: backend agents has no server available!
[WARNING]  (37) : Server agents/agent1 is UP, reason: Layer7 check passed, code: 0, check duration: 5ms. 1 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.

Server configuration

Web server: Nginx

Database: Maria

PHP version: 8.3

Nextcloud version: 32

Browser

Browser name: Arc
Browser version: 141.0.7390.108

Operating system: Windows

More Notes

After much head scratching I checked out this repo and increased the last sleep to 10s:

HaRP/start.sh

Lines 311 to 319 in 079eef3

log "INFO: Starting FRP server on ${HP_FRP_ADDRESS}..."
frps -c /frps.toml &
sleep 1s
if [ -e "/var/run/docker.sock" ]; then
log "INFO: Starting FRP client for Docker Engine..."
frpc -c /frpc-docker.toml &
fi

Now the logs looks much better and the test connection from Nextcloud worked:

INFO: FRP server configuration generated at /frps.toml.
INFO: Detected /var/run/docker.sock, generating /frpc-docker.toml configuration file...
INFO: Starting Python HaProxy Agent on 127.0.0.1:8200 and 127.0.0.1:9600...
INFO: Starting FRP server on 0.0.0.0:8782...
INFO: Starting FRP client for Docker Engine...
INFO: Starting HAProxy...
2025-10-18 18:52:39.790 [I] [sub/root.go:142] start frpc service for config file [/frpc-docker.toml]
2025-10-18 18:52:39.791 [I] [client/service.go:295] try to connect to server...
[NOTICE]   (1) : Initializing new worker (68)
2025-10-18 18:52:39.858 [I] [client/service.go:287] [a8a00d2229365789] login to server success, get run id [a8a00d2229365789]
2025-10-18 18:52:39.859 [I] [proxy/proxy_manager.go:173] [a8a00d2229365789] proxy added: [bundled-deploy-daemon]
2025-10-18 18:52:39.865 [I] [client/control.go:168] [a8a00d2229365789] [bundled-deploy-daemon] start proxy success
[NOTICE]   (1) : Loading success.

10s is obviously too long for a standard config, but is there a more reliable way of testing whether the FRP server is up and able to take connections?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions