To access Caché Session (Terminal) without password, you should make two steps:

1. Check if the UnknownUser has got appropriate roles (e.g. %All) in System Administration | Security | Users. As a minimum it should have role with %Development resource and resource for given database (e.g. %DB_USER for access  to USER namespace).

2. Un-check Password and allow Unauthenticated access for service %Service_Terminal in System Administration | Security | Services. This is for linux/Unix systems. For Windows you should enable Unauthenticated access for %Service_Console and %Service_Telnet.

You are right that if you access frameset page from another CSP page, all frames should use the same session.

5916 Illegal CSP Request error happens if you access encrypted or private CSP page with incorrect session token. I guess if it can be because of some cached pages in the browser. Do you use cookies to identify the session? And what happens if you make a forced refresh of the frameset page (CTRL-F5), does it  load correctly then?

As Dmitry wrote above, you shouldn't use  http://localhost:57772/csp/samples/REST.DocServer.cls ,  this is not correct call for REST services.

Correct URL to get list of namespaces is http://localhost:57772/csp/samples/docserver/namespaces in with GET method. Look at the http://localhost:57772/csp/documatic/%25CSP.Documatic.cls?LIBRARY=samples&CLASSNAME=REST.DocServer  class documentation for further available methods.

Please, are you able to log into Caché Terminal?

The best start to debug such kind of problems is to enable Security Audit (if not already enabled) and Login, LoginFailure and Protect system events using ^SECURITY routine (option 6 - Auditing setup) in %SYS namespace:

USER>ZN "%SYS"
%SYS>Do ^SECURITY

Then reproduce the error and view the Audit, check for the latest records - you should see LoginFailure or Protect events there. Check details of given record, it should tell you more about the problem.

It depends on selected initial security during installation.  Using Minimal Security it doesn't set CSPSystem user for CSP Gateway Server Access, therefore unauthenticated access with UnknownUser is used.

Basics of Initial Caché Security Settings are described in Caché documentation:

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

The best start to debug such kind of problems is to enable Security Audit (if not already enabled) and Login, LoginFailure and Protect system events using ^SECURITY routine (option 6 - Auditing setup).

Then reproduce the error and view the Audit, check for the latest records - you should see LoginFailure or Protect events there. Check details of given record, it tells you more about the problem.

In your case it was LoginFailure event with error message:  User UnknownUser account is disabled.

The files looks same if you open it e.g. in Windows Notepad. This is because Notepad recognize the file as UTF-8 even if the BOM is missing but file contains some Unicode characters (>255). If you write pure ASCII ("Hello"), it will be open as ANSI file.

But if you open it in any hexadecimal editor you would see the second file is missing BOM.

EDIT: I found it sets the BOM property only if you set it AFTER setting of translation table:

 Set stream=##class(%Stream.FileCharacter).%New()
 Set sc=stream.LinkToFile("c:\temp\UTF8ExampleWithBom.txt")
 Set stream.TranslateTable="UTF8"
 Set stream.BOM=$C(239,187,191)
 Do stream.Write("Hello")
 w stream.%Save()

This is because setting of TranslateTable reset BOM to empty string again.

AFAIK there is not any default timeout on Caché WebSocket implementation in the Caché server or CSP gateway. It  just open a persistent connection between CSP Gateway and Caché server (if SharedConnection=0) to allow to exchange messages.

If the connection is closed for some reason, I would start to look at some intermediates - like firewall, proxy or any other tool which could close the connection. 

Or maybe your websocket implementation does it?

It is not client name but Caché Username ($USERNAME). The 'Username' cookie is set by Management Portal, it's just to remember last user who was logged on. You cannot depend on this cookie in your application.

To get the client name, you should check some other CGIENV variables, like REMOTE_ADDR resp. REMOTE_USER. But it doesn't always exist.

Please, let us know what information you are looking for. Do you need to know name of the remote user connecting to the application?

You can also use syntax:

 set currPath=$SYSTEM.Process.CurrentDirectory()
 set oldPath=$SYSTEM.Process.CurrentDirectory(newPath)

The CurentDirectory method is an API covering the internal $ZUTIL functions:

ClassMethod CurrentDirectory(dir As %String) As %String
{
 quit:'$d(dir) $zu(168)
 quit $zu(168,dir)
}

Therefore in older Caché versions you can use:

 set currPath=$ZU(168)
 set oldPath=$ZU(168,newPath)