# SonarLink

{% hint style="info" %}
Use Version [1.12.3-beta](https://github.com/CeruleanSonar/SonarView/releases/tag/v1.12.3-beta) (or newer) for the following functionality.&#x20;
{% endhint %}

\
\
The SonarView application comprises browser-compatible web application with all the UI and most of the functionality, plus a second process called SonarLink which handles all connections to the real world that are not possible to access via browser technology.&#x20;

SonarLink is a node.js server-side application which runs as a separate process from the web-compatible SonarView application. SonarView and SonarLink are bundled together in a single (Electron) executable available for Windows, MacOS, or Linux.

While the bundled application includes both SonarView and SonarLink, SonarView can optionally connect to remote instances of SonarLink rather than the local bundled one. The SonarLink connection are specified in the user settings as documented in [Application Settings](/c/sonarview/application-settings.md).&#x20;

You can run multiple instance of SonarView on the same computer. In this scenario, only a single SonarLink instance is actually active. This is transparent to the user.&#x20;

## HTTP interface

Among other functions, SonarLink hosts an http interface on port 7077. This interface can be used to access status information as described here.

### Status

The `/status` endpoint reports a bunch of useful information about SonarLink as a `JSON`object. This includes SonarLink's host machine and network interfaces, as well as any currently active sessions.

`GET http://host:port/status`

Where host is the ip address (typically 127.0.0.1 or localhost), and port is 7077.

In particular, this can be used to identify existing sessions and getting their session\_id.

## Listen-Only WebSocket

Here we describe a scenario where SonarView is connected to a sonar and a 3rd party application wants to "listen in" on all the data coming from the sonar so that it can process the live information in real time.

Here is how you might open a listen-only web socket to an existing session already opened by SonarView. We're assuming SonarLink is running on localhost.

1. Submit a HTTP GET to `http://localhost:7077/status` . This will return the current status of SonarLink and list all active sessions. If an appropriate session already exists, find the session id in this JSON object at `status.sessions[index].session_id`.
2. Open a WebSocket connection like `ws://localhost:7077/connect_ws?session_id=1`.

Now all data coming from the sonar (and other devices in the session if any) will be sent to this web socket. The data is a stream of Cerulean Ping Protocol packets. The 3rd party application is then responsible to parse the data and process as desired. For information on the packet formats consult the API section for the particular sonar as well as the [Cerulean Ping Protocol](https://docs.ceruleansonar.com/c/cerulean-ping-protocol) document.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ceruleansonar.com/c/sonarview/sonarlink.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
