> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/6.15/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/6.15/troubleshooting.md).

# Troubleshooting

## TPOSS diagnosis with the observer tool

You can use [observer diagnosis TUI](https://github.com/zhongwencool/observer_cli) to get insight into TPOSS internals. Follow these steps to use observer:

1. Start a new shell process in the TPOSS container:

```bash
kubectl exec -it tposs-pod-name bash -n namespace -c tposs
```

2. Connect to the TPOSS remote console:

```bash
./run.sh remote
```

3. Start the observer CLI tool:

```elixir
:observer_cli.start()
```

The result is a TUI that provides an overview of the TPOSS internal components and their state. You can use it for the analysis of TPOSS performance and other issues.

## Clean-up of sessions and IPs

To clean up all the active sessions and related IP addresses, use the following command in the TPOSS remote console:

```elixir
Tposs.ReplHelpers.clean_sessions()
```

TPOSS provides a way to automatically clean up service sessions. For more information, see the [Automatic service session cleanup](https://docs.cennso.com/components/tposs/6.15/configuration/session.md#automatic-service-session-cleanup) section.

## Reinitialize metrics

The accuracy of the counters that are used for TPOSS metrics highly depends on the database. The values of the counters can be invalid because of any database-related failure. To reinitialize the metrics, run this command in the TPOSS remote console:

```elixir
:rpc.multicall(Tposs.Utils.get_nodes, Tposs.Metrics.Db, :fetch_data_for_metrics, [1000000, 5])
```

### Reinitialize the `sessions_GGSN` metric

Launching TPOSS in the setup with a high number of MCCs, MNCs, and home countries may lead to a high number of the `sessions_GGSN` metrics with different labels. It is possible to disable a certain label or all labels of this metric. To specify a set of labels of the `sessions_GGSN` metric at runtime, run this command in the TPOSS remote console:

```elixir
Tposs.Metrics.reinit_network_session_labels([:visitedNetworkMCC, :visitedNetworkMNC, :activeProfile], 30_000)
```

The first argument of the command is the list of labels with which you want to reinitialize the metric. To disable all the labels, run the command with an empty list - `[]`. The second argument is the timeout for TPOSS to run a query to the database in order to fetch information to reinitialise the metric. The timeout is provided in milliseconds.

## Disable the service session cleanup service

Some issues may occur if you have a huge number of outdated service sessions and run the [automatic service sessions cleanup](https://docs.cennso.com/components/tposs/6.15/configuration/session.md#automatic-service-session-cleanup) service too often. In that case, the deletion of a huge number of records from the database may bring negative impact on the database performance and resource consumption. To reduce the possibility of deleting too many sessions at once, you can completely disable the service sessions cleanup service without restarting TPOSS. To do so, run the following command in the TPOSS remote console:

```elixir
Tposs.Pcs.ScgCleanupService.disable_service_session_cleanup_service()
```

During the next maintenance period, you can re-configure the service sessions cleanup service to delete fewer outdated sessions at once. To do so, raise the limit of the deleted sessions and reduce the time to check for such sessions. For more information, read the parameter descriptions in the [Automatic service sessions cleanup](https://docs.cennso.com/components/tposs/6.15/configuration/session.md#automatic-service-session-cleanup) section.

## MySQL `1406` error - data too long for column

Most of the table columns used by TPOSS to store string-like data are of the [varchar(256)](https://dev.mysql.com/doc/refman/8.0/en/char.html) data type. If you provide too long data, the column size may not be enough. In such a case, the MySQL `1406` error occurs. To solve the issue, increase the size of a column with the following command:

```sql
ALTER TABLE {TABLE-NAME} MODIFY {COLUMN-NAME} VARCHAR( { NEW-SIZE } );
```

## Observe the state of the idle timer process

If you consider your session as idle but TPOSS does not terminate it, you can observe the state of the process that checks expired [idle timers](https://docs.cennso.com/components/tposs/6.15/configuration/session.md#idle-session-management) with the following command:

```elixir
> Tposs.Pcs.Session.Database.Timer.Watcher.get_next_period()
```

The output of this command is the UTC date and time of the next check for the expired idle timers. The format is `YYYY-MM-DDTHH:MM:SSZ`.

>**NOTE:** The returned value of `Tposs.Pcs.Session.Database.Timer.Watcher.get_next_period()` is an estimate and may not be perfectly accurate, but it should be close to the real-time. If the returned value is significantly different from the real-time, such as being 1 minute behind, please open a ticket.

## Capturing traffic

You can inspect the incoming and outgoing traffic using [tcpdump](https://www.tcpdump.org/) or any other tool to capture TPOSS traffic. The main TPOSS container is a rootless container with the user that can not write data on disk. This means you may not have enough permissions to capture and store captured traffic inside the TPOSS container. For this case, TPOSS provides support for a [sidecar container](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/). You can enable the `networkUtility` sidecar container in the TPOSS deployment for debugging purposes using the following configuration options:

```yaml
networkUtility:
  enabled: true
  image:
    repository: quay.io/travelping/nettools
    tag: v1.12.0
    pullPolicy: IfNotPresent
```

TPOSS provides the following interfaces and ports on which you can capture and collect traffic:

- RADIUS - The underlying protocol is `UDP`. The default ports are `1812` (RADIUS authentication), `1813` (RADIUS accounting) and `3799` ([RADIUS CoA and Disconnect](https://datatracker.ietf.org/doc/html/rfc5176)). The ports of the TPOSS RADIUS servers might be different in a live deployment. For more information, see the [RADIUS settings](https://docs.cennso.com/components/tposs/6.15/configuration/radius.md).
- Diameter - The underlying protocol is `TCP`. The default port is `3868`. The port of the TPOSS Diameter server might be different in a live deployment. For more information, see the [Diameter settings](https://docs.cennso.com/components/tposs/6.15/configuration/diameter.md).
- TPOSS HTTP API - The underlying protocol is `TCP`. The default port is `8080`. The port of the TPOSS HTTP server might be different in a live deployment. For more information, see the [API overview](https://docs.cennso.com/components/tposs/6.15/api-reference/api.md).
- SBI - The underlying protocol is `TCP`. The default port is the same as the `TPOSS HTTP API`.

Using the debug sidecar container, you can run `tcpdump` utility for the temporary traffic capturing. To do so, run this command:

```bash
( kubectl -ntesting exec tposs-tposs-0 -ctposs-debugging-sidecar -- tcpdump -p -w - -s0 udp port 1812 or 1813 or 3799 -lUni any | sudo wireshark -k -i - )
```

The output from tcpdump is redirected to locally launched [Wireshark](https://www.wireshark.org/). It allows you to observe and filter the captured traffic. To rotate files with the captured traffic, you can use the [standard tcpdump options](https://www.tcpdump.org/manpages/tcpdump.1.html) `-G` and `-w` with the suitable values:

```bash
tcpdump -s0 udp port 1812 or 1813 or 3799 -lUni any -W 10 -C 1 -G 1800 -w 'trace_%Y_%m_%d_%H_%M_%S.pcap'
```

To simplify capturing and analysing the traffic, you can collect only a certain part using the tcpdump or Wireshark filtering. Here is the list of the Wireshark filters that you can use to analyze the incoming and outgoing traffic:

- `radius` - filter the RADIUS packets only.
- `diameter` - filter the Diameter packets only.
- `radius || diameter` - filter the RADIUS and Diameter packets only.
- `diameter.cmd.code != 280` - exclude Diameter watchdog messages.
- `e212.imsi = {IMSI}` - filter requests by IMSI.
- `radius.Framed-IP-Address == {FRAMED-IP-ADDRESS} || diameter.Framed-IP-Address == "{FRAMED-IP-ADDRESS}"` - filter requests by RADIUS and Diameter packets with the given `Framed-IP-Address`.
- `diameter.Session-Id == {SESSION-ID} || e212.imsi == {IMSI}` - filter requests by the `Session-Id` and IMSI to catch the network and service sessions related to each other.
- `frame.number in {100, 102}` - filter packets with the given frame numbers. It can be useful to show the RADIUS or Diameter responses for the filtered requests.

You can find more information on filtering RADIUS and Diameter packets in the [RADIUS protocol filter reference](https://www.wireshark.org/docs/dfref/r/radius.html) and [Diameter protocol filter reference](https://www.wireshark.org/docs/dfref/d/diameter.html).
