Simple Proof of Concept with Sync Gateway 3.20

Hello,
Im trying to get the Sync Gateway running with the ios userprofile example to know, if this server is suitable for me.

First problem:
Was failing to run the docker compose scripts. The Init Couchbase Server is failing. I have needed to go into the docker container and execute all the commands again manually. So the automatic script/example is not really working.

Second problem:
Example is not up to date. I want to run a simple PoC, where I sync two different collections. The example just uses the default collection + default scope. I have then changed a little bit of the Replicator Initialization (adding default collection + custom collection). Then at least the default collection with the user profile is working. But it complains, that the remote server has not the custom collection. I tried different things now, but for me the documentation is not very clear.

What I have found until now:
The sync gateway configuration seems to be based on the old 2.X version, which has already everything included with database stuff and so on. But the 3.X version has splitted all this things up. So I need to initialize the stuff with the bootstrap configuration and then get the database configuration at some other way on the sync gatway?

Following is the modified sync gateway config json:

{
  "api": {
    "admin_interface": "127.0.0.1:4985",
    "public_interface": ":4984"
  },
  "bootstrap": {
    "server": "couchbase://couchbase-server",
    "server_tls_skip_verify": true,
    "use_tls_server": false,
    "password": "P@ssw0rd12",
    "username": "Administrator"
  },
  "database_credentials": {
    "userprofile": {
      "username": "admin",
      "password": "P@ssw0rd"
    }
  },
  "logging": {
    "log_file_path": "/var/tmp/sglogs",
    "console": {
      "log_level": "debug",
      "log_keys": ["*"]
    },
    "error": {
      "enabled": true,
      "rotation": {
        "max_size": 20,
        "max_age": 180
      }
    },
    "warn": {
      "enabled": true,
      "rotation": {
        "max_size": 20,
        "max_age": 90
      }
    },
    "info": {
      "enabled": false
    },
    "debug": {
      "enabled": true 
    }
  }
}

At least this is the first configuration where the sync gateway is starting. But it’s absolutely not reachable with the admin interface. Also telnet is directly closing the connection if I want connect to that port.

But in the logs its just saying it trying to attempt to get the configuration from the bucket.

2024-09-22T10:42:36.588Z [DBG] Config+: b:userprofile Checking for database config (attempt 1/5)
2024-09-22T10:42:36.589Z [DBG] Config+: b:userprofile Bucket "userprofile" did not contain any configs for group "default"
2024-09-22T10:42:36.589Z [WRN] Config: No database configs for group "default". Continuing startup to allow REST API database creation -- rest.(*ServerContext).initializeBootstrapConnection() at server_context.go:2154
2024-09-22T10:42:36.589Z [INF] Config: Starting background polling for new configs/buckets: 10s
2024-09-22T10:42:36.589Z [INF] Finished initializing bootstrap connection
2024-09-22T10:42:36.589Z [INF] Diagnostic API not enabled - skipping.
2024-09-22T10:42:36.589Z [INF] Starting metrics server on 127.0.0.1:4986
2024-09-22T10:42:36.589Z [INF] Starting admin server on 127.0.0.1:4985
2024-09-22T10:42:36.589Z [INF] Starting server on :4984 ...
2024-09-22T10:42:46.590Z [DBG] Config+: Fetching configs from buckets in cluster for group "default"
2024-09-22T10:42:46.597Z [DBG] Config+: b:userprofile Checking for database config (attempt 1/5)
2024-09-22T10:42:46.598Z [DBG] Config+: b:userprofile Bucket "userprofile" did not contain any configs for group "default"
2024-09-22T10:42:56.591Z [DBG] Config+: Fetching configs from buckets in cluster for group "default"
2024-09-22T10:42:56.597Z [DBG] Config+: b:userprofile Checking for database config (attempt 1/5)
2024-09-22T10:42:56.598Z [DBG] Config+: b:userprofile Bucket "userprofile" did not contain any configs for group "default"
2024-09-22T10:43:06.591Z [DBG] Config+: Fetching configs from buckets in cluster for group "default"
2024-09-22T10:43:06.599Z [DBG] Config+: b:userprofile Checking for database config (attempt 1/5)
2024-09-22T10:43:06.600Z [DBG] Config+: b:userprofile Bucket "userprofile" did not contain any configs for group "default"
2024-09-22T10:43:16.591Z [DBG] Config+: Fetching configs from buckets in cluster for group "default"
2024-09-22T10:43:16.598Z [DBG] Config+: b:userprofile Checking for database config (attempt 1/5)
2024-09-22T10:43:16.599Z [DBG] Config+: b:userprofile Bucket "userprofile" did not contain any configs for group "default"

I would assume, after I would get this sync gateway into a running state, I need to create the database configuration with the API? Or is there a simpler, more automatic way, by giving that configuration directly at startup?

Yeah, you’re correct. Once created, it’s stored in Couchbase Server and it’s a one-time operation, no matter how many nodes of Sync Gateway you are running. It’s a bit more painful for local development and testing, but provides large benefits when deploying and managing production instances.

This line in your configuration means the port is only bound to the local interface. If you’re running Sync Gateway inside docker, the admin port is only accessible from the container itself. You may want to change this to :4985 if you want to access the Admin API externally.

    "admin_interface": "127.0.0.1:4985",
2024-09-22T10:42:36.589Z [INF] Starting admin server on 127.0.0.1:4985

Hi - where is this example? I’ll try to find the owner.

I have used this example:

I’ve notified the owner.

oh my god. Thanks a lot, that was the issue. It’s nearly embarrassing.

But at least I have addressed the stuff. I think this would be really helpful for newbies to update the examples to the new version configuration.

Regarding the issue with the docker scripts, that the couchbase server init is failing. Later I have tried to increase the delays in that init-cbserver.sh script. And that helps. Then I can also use the docker-compose script to start the stuff automatically.

2 Likes