> For the complete documentation index, see [llms.txt](https://support.marscat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.marscat.io/development-guide/backend-development/self-service-operations/troubleshooting.md).

# Troubleshooting

{% stepper %}
{% step %}

### Service Startup Failure

#### Symptoms

* Docker container fails to start
* Service process exits abnormally
* Port access failure

#### Diagnosis Steps

**Check Port Usage**

```bash
netstat -tlnp | grep -E "(4567|4568|27017)"
```

**Validate Configuration Files**

```bash
# Check configuration file syntax
docker-compose config

# View detailed startup logs
docker-compose up --no-daemon
```

**Check Docker Images**

```bash
docker images | grep selfservice
```

#### Solutions

* Port Occupied: Modify the port in the configuration file or stop the program occupying the port
* Configuration File Errors: Check JSON syntax and YAML format
* Image Missing: Re-execute `docker load -i selfservice.tar`
  {% endstep %}

{% step %}

### P2P Network Connection Failure

#### Symptoms

* Unable to connect to P2P network
* Certificate validation failure
* Network timeout

#### Diagnosis Steps

**Check P2P Configuration**

```bash
cat pango.conf
```

**Validate Certificate Expiry**

```bash
CERT_EXPIRED=$(grep routecertexpired pango.conf | cut -d'=' -f2)
CURRENT_TIME=$(date +%s)
if [ $CURRENT_TIME -gt $CERT_EXPIRED ]; then
    echo "Certificate expired, needs update"
fi
```

**Test Network Connectivity**

```bash
ping -c 3 x08.a867744.com
```

#### Solutions

* Certificate Expired: Obtain a new Self Service certificate and update `pango.conf`
* Network Issues: Check firewall and network connectivity
* Configuration Errors: Confirm correctness of `t2trepeater` and other parameters
  {% endstep %}

{% step %}

### Application Service Connection Failure

#### Symptoms

* Self Service node cannot access application service
* API call timeout or failure
* Connection refused

#### Diagnosis Steps

**Check Application Service Configuration**

```bash
grep "remoteService" config.json
```

**Test Application Service Connectivity**

```bash
REMOTE_SERVICE=$(grep -o '"remoteService": "[^"]*"' config.json | cut -d'"' -f4)
curl -v $REMOTE_SERVICE
```

**Validate Network Connectivity**

```bash
# Test TCP connection
telnet $(echo $REMOTE_SERVICE | sed 's|http://||' | cut -d':' -f1) $(echo $REMOTE_SERVICE | sed 's|.*:||' | cut -d'/' -f1)
```

#### Solutions

* Application Service Not Running: Start the application service
* Address Misconfiguration: Modify the `remoteService` address in `config.json`
* Firewall Blocking: Adjust firewall rules or network security groups
  {% endstep %}

{% step %}

### Database Connection Issues

#### Symptoms

* MongoDB connection failure
* Database authentication errors
* Abnormal data operations

#### Diagnosis Steps

**Check MongoDB Status**

```bash
# View MongoDB logs
docker logs mongodb-service

# Enter container to check connection
docker exec -it mongodb-service mongosh

# Test database connection
docker exec mongodb-service mongosh --eval "db.runCommand({connectionStatus: 1})"
```

**Validate Configuration**

```bash
grep -A 10 '"mongo"' config.json
```

#### Solutions

* Incorrect Password: Ensure password consistency between `config.json` and `docker-compose.yml`
* Container Startup Failure: Inspect MongoDB container logs for startup issues
* Network Problems: Ensure network connectivity between containers
  {% endstep %}

{% step %}

### Self Service Registration Failure

#### Symptoms

* Self Service fails to register in MarsApp
* Service status abnormal

#### Diagnosis Steps

**Check Service Key**

```bash
curl http://127.0.0.1:4567/getServiceKey
```

**View Registration Logs**

```bash
# Check registration logs, look for:
# - Registration messages (info level)
# - Latest successful registration time (info level)
grep -E "(register|auth|key)" data/logs/$(date +%Y-%m-%d)-self.log
```

**Validate Service Status**

```bash
curl http://localhost:4567/health | grep -o '"status":[0-9]*'
```

#### Solutions

* Service Key Mismatch: Ensure consistency between Self Service and MarsApp key values
* Configuration Errors: Check `pango.conf` configuration
* Certificate Expired: Update `routecert` and `routecertexpired` parameters
* Registration Configuration Reset: After deleting the MarsApp and reinstalling, the Self Service can be re-registered
  {% endstep %}

{% step %}

### No Response After Successful Self Service Registration

#### Symptoms

* No response after sending messages
* Message transmission interrupted

#### Diagnosis Steps

**Self Service Node to Application Service Connection**

```bash
REMOTE_SERVICE=$(grep -o '"remoteService": "[^"]*"' config.json | cut -d'"' -f4)
curl -v $REMOTE_SERVICE
```

**View Message Processing Logs**

```bash
# Monitor logs, check for:
# - Incoming messages (non-registration messages, info level)
# - Application service API call info including endpoints, parameters, and return values (debug level)
tail -f data/logs/$(date +%Y-%m-%d)-self.log | grep -E "(request|response|message)"
```

#### Solutions

* No Response from Application Service: Ensure application service is running properly, confirm API endpoint correctness
* Self Service Network Issues: Check network stability, may require restarting the Self Service node
* Improper Timeout Configuration: Adjust client timeout settings
* Message Format Errors: Verify API call data format and endpoint paths
* Registration Configuration Reset: After deleting the MarsApp and reinstalling, the Self Service can be re-registered
  {% endstep %}
  {% endstepper %}
