# Document Editor and Viewer

> Fix a Document Editor or Viewer that stays empty: not registered, WebSocket fails or drops, TXTextControl.init errors, a viewer script 401, React with Vite.

- **Product:** DS Server
- **Section:** Documentation
- **Kind:** Topic
- **Path:** DS Server > Troubleshooting > Document Editor and Viewer
- **2464 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/troubleshooting/editor-viewer/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/troubleshooting/editor-viewer/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/troubleshooting/editor-viewer/llms-full.txt

---

The Document Editor and the Document Viewer run in the browser, but their scripts, their access token and their document processing come from DS Server. When one of them stays empty, shows a message instead of a document or throws an error on the page, the cause is usually on the way between the browser and DS Server. Start with the browser console, then find the message you see among the problems below.

### Find Out Where It Fails

Two places show most of what goes wrong:

1. **The browser console**, opened with F12. The Document Editor logs the address of its WebSocket connection, for example:

    ```text
    Connecting to ws://localhost:5000/documenteditor/WS
    ```

    Errors of the token request, of the WebSocket connection and of the license check appear below it. The change log of version 5.0 also announces a console message for a TCP server of the Document Editor that isn't running, but the editor script of DS Server 5.0.2 doesn't contain such a message, so don't rely on it.
2. **The log file of DS Server** in its *logs* folder, as [Find Out Whether the Server Runs](https://docs.textcontrol.com/ds-server/troubleshooting/installation/#find-out-whether-the-server-runs) describes. It records refused tokens and license warnings.

The Angular, React and ASP.NET Core packages load the same scripts from DS Server, so the messages below apply to them as well.

### The Editor or Viewer Says DS Server Is Not Registered

The Document Editor shows a gray area with a box that reads:

```text
DS Server is not registered.
```

![The Document Editor area in gray with a white box in the middle that reads "DS Server is not registered."](https://docs.textcontrol.com/assets/img/ds-server/editor-not-registered.fc18aa7f.webp)

The browser console of the editor reports `License error: DS Server is not registered.` The Document Viewer writes the same message in red at the top of the page and logs it to the console, and a page that then calls `TXDocumentViewer.init` reports `TXDocumentViewer is not defined`: instead of the viewer, DS Server delivers a short script that only writes this message.

![The text "DS Server is not registered." in red, written by the Document Viewer script into the page.](https://docs.textcontrol.com/assets/img/ds-server/viewer-not-registered.b1b7781b.webp)

DS Server isn't registered. An unregistered server blocks the editor, the viewer and the DocumentProcessing endpoints of the Web API; it has no mode that works with a watermark instead. The admin portal, the OAuth endpoints and the administration endpoints keep working.

1. Register DS Server in the admin portal under **Licensing**, as [Licensing](https://docs.textcontrol.com/ds-server/administration/licensing/llms-full.txt) describes.
2. Reload the page with the editor or viewer.

To evaluate the components without a license of your own, use a [Trial Token](https://docs.textcontrol.com/ds-server/getting-started/trial-token/llms-full.txt) with the trial server that Text Control runs at `https://trial.dsserver.io`.

### The Editor Can't Connect to the Server

The editor area shows:

```text
Can't connect to the server.
Please refresh the website to re-connect.
```

The editor couldn't open its WebSocket connection to `<service URL>/documenteditor/WS`, or the connection closed before the editor had loaded. The console shows why:

- **The WebSocket had no valid token.** With OAuth enabled, a connection without a token fails with:

    ```text
    WebSocket connection to 'ws://localhost:5000/documenteditor/WS' failed: HTTP Authentication failed; no valid credentials available
    ```
- **IIS doesn't pass WebSockets.** When DS Server runs under IIS, the Windows feature **WebSocket Protocol** (`IIS-WebSockets`) must be installed, as the [Requirements](https://docs.textcontrol.com/ds-server/installation/requirements/llms-full.txt) list.
- **A proxy or load balancer doesn't pass WebSockets** to DS Server. The .NET Server's page [WebSockets](https://docs.textcontrol.com/tx-text-control-dotnet-server/troubleshooting/websockets/#a-proxy-or-web-server-doesn-t-pass-the-websocket) describes the headers nginx needs to forward a WebSocket.

To fix it:

1. Pass a valid access token, or a client ID and secret, in the `authSettings` of [TXTextControl.init](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/init-method/llms-full.txt), or in the OAuth settings of your client package. [Authentication](https://docs.textcontrol.com/ds-server/troubleshooting/authentication/llms-full.txt) covers failing token requests.
2. On IIS, install the **WebSocket Protocol** feature and restart the site. The .NET Server's page [IIS](https://docs.textcontrol.com/tx-text-control-dotnet-server/troubleshooting/iis/#the-editor-doesn-t-connect) shows where the feature is in Server Manager.
3. Configure every proxy between the browser and DS Server to forward the WebSocket requests to */documenteditor/WS*.

### The Editor Loses Its Connection

The editor blocks input and shows:

```text
Connection lost. Reconnecting…
```

The WebSocket closed while the user was editing, and the console logs `WebSocket connection lost.` The editor tries to reconnect to its session until the time in [reconnectTimeout](https://docs.textcontrol.com/ds-server/reference/javascript/documenteditorsettings/reconnecttimeout-property/llms-full.txt) has passed, 30 seconds unless you set it. If the connection doesn't return in time, the console logs `Could not reconnect.` and the editor shows the connection message of the previous section.

1. To give the connection more time, set `reconnectTimeout` in the `editorSettings` of `TXTextControl.init`, or the setting of the same name in your client package.
2. Update DS Server if it's older than 5.0.1: several releases fixed lost and failed reconnections, as [Problems Fixed by an Update](#problems-fixed-by-an-update) lists.

### TXTextControl.init Throws an Error

In an HTML page that loads *ds-server-document-editor.js* from DS Server, the editor doesn't appear and the console shows one of these errors:

```text
Missing container ID.
Container element with id '<id>' not found.
Missing service URL.
Invalid service URL '<url>'.
OAuth error: Missing client secret.
```

`TXTextControl.init` checks its settings before it connects:

| Message | Cause | Fix |
|---|---|---|
| `Missing container ID.` | `containerID` is missing or isn't a string | Pass the `id` of the `div` element that holds the editor |
| `Container element with id '<id>' not found.` | The page has no element with this `id` when `init` runs | Call `TXTextControl.init` after the element exists, for example at the end of the `body` |
| `Missing service URL.` | `serviceURL` is missing | Pass the address of DS Server |
| `Invalid service URL '<url>'.` | `serviceURL` doesn't start with `http://` or `https://` | Pass the full address, for example `https://dsserver.example.com` |
| `OAuth error: Missing client secret.` | A `clientId` without `clientSecret` | Pass both, or an access token instead |

Without `authSettings`, `TXTextControl.init` doesn't report an error: the editor connects without a token. That works only while OAuth is disabled; with OAuth enabled, the connection fails as [The Editor Can't Connect to the Server](#the-editor-can-t-connect-to-the-server) describes.

When `authSettings` holds both an access token and a client ID, the editor uses the token and warns:

```text
OAuth access token and client ID must not be present simultaneously. Resetting client ID and client secret.
```

When the editor requests the token itself with a client ID and secret and DS Server refuses it, for example because the security profile doesn't allow the client credentials grant type, the console shows `Could not retrieve OAuth token.` followed by the `error` and `error_description` of DS Server. See [The Token Request Says the Grant Type Isn't Allowed](https://docs.textcontrol.com/ds-server/troubleshooting/authentication/#the-token-request-says-the-grant-type-isn-t-allowed).

The Getting Started page [JavaScript](https://docs.textcontrol.com/ds-server/getting-started/document-editor/javascript/llms-full.txt) shows a complete page.

### The Viewer Script Doesn't Load

In an HTML page, the Document Viewer doesn't appear, the console reports `TXDocumentViewer is not defined`, and the network tab shows status 401 for the request of *GetResource*.

A page without a client package loads the viewer script from `<service URL>/documentviewer/TextControl/GetResource?Resource=minimized.tx-viewer.min.js`. With OAuth enabled, DS Server delivers the script only with a valid token in the query parameter `access_token`.

1. Request an access token on your server, as [Authentication](https://docs.textcontrol.com/ds-server/troubleshooting/authentication/llms-full.txt) describes.
2. Append it to the script address: `...&access_token=<access token>`.
3. Pass the same token in `oauthSettings: { accessToken }` of the viewer settings, and set `basePath` to `<service URL>/documentviewer`.

The Getting Started page [JavaScript](https://docs.textcontrol.com/ds-server/getting-started/document-viewer/javascript/llms-full.txt) shows a complete page, and the [TXDocumentViewer](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/llms-full.txt) reference lists the settings.

### The React Component Isn't Rendered

In a React application created with Vite 8, the editor or viewer doesn't render, and React reports an invalid element type.

The React packages are CommonJS modules. Vite 8 returns the whole module for their default import instead of the component.

1. Take the component from the `default` export when there is one, as [React](https://docs.textcontrol.com/ds-server/client-libraries/react/#install-the-packages) shows:

    ```jsx
    import DocumentEditorPackage from '@txtextcontrol/tx-react-ds-document-editor';

    const DocumentEditor = DocumentEditorPackage.default ?? DocumentEditorPackage;
    ```
2. Do the same for `@txtextcontrol/tx-react-ds-document-viewer`.

### Problems Fixed by an Update

The change log of DS Server lists these fixes of the Document Editor and the Document Viewer. If you see one of the problems with an older version, update DS Server and the client packages, as [Upgrading](https://docs.textcontrol.com/ds-server/installation/upgrading/llms-full.txt) describes.

| Problem | Fixed in |
|---|---|
| The WebSocket connection failed during local development when the application and DS Server used different protocols, HTTP and HTTPS | 3.3.0 |
| Reconnecting after a lost connection failed in some cases, and the reconnect timeout couldn't be set | 3.3.0 |
| The editor loaded its JavaScript twice in React or Blazor strict mode, which caused an error | 3.4.0 |
| Fast scrolling dropped the connection | 3.5.0 |
| The editor didn't find the right 64-bit *dotnet.exe* on Windows | 5.0.0 |
| Signatures were missing from the exported document of the Document Viewer, and signing didn't work | 5.0.0 |
| DS Server crashed when a Document Editor session reconnected | 5.0.1 |
| *TXSpell.dll* was missing from the *core* folder | 5.0.1 |
| DS Server crashed in rare cases while it cleaned up a Document Editor worker process | 5.0.2 |

[What's New](https://docs.textcontrol.com/ds-server/whats-new/llms-full.txt) describes each version.

### Related Pages

- [Authentication](https://docs.textcontrol.com/ds-server/troubleshooting/authentication/llms-full.txt): token requests and requests that DS Server refuses.
- [Installation](https://docs.textcontrol.com/ds-server/troubleshooting/installation/llms-full.txt): the server doesn't start or isn't registered.
- [Client-Side Libraries](https://docs.textcontrol.com/ds-server/client-libraries/llms-full.txt): the Angular, React and ASP.NET Core packages and their settings.
- [Document Editor](https://docs.textcontrol.com/ds-server/getting-started/document-editor/llms-full.txt) and [Document Viewer](https://docs.textcontrol.com/ds-server/getting-started/document-viewer/llms-full.txt) in Getting Started: working first applications.

---

## Nearby

- **Previous:** [Authentication](https://docs.textcontrol.com/ds-server/troubleshooting/authentication/llms-full.txt)
- **Next:** [Linux](https://docs.textcontrol.com/ds-server/troubleshooting/linux/llms-full.txt)
