The JANOS Web Server listens for connections from clients that are running one of the many popular browser programs. Typically ports 80 and 443 (for secure TLS/SSL communications) are open for connection although those are configurable through the JNIOR Registry. In addition to the default HTTP Protocol a connection may also utilize the Websocket Protocol as described in this document. The Web Server ports are shared by these two protocols. This provides for access to status information and control commands that previously were only available through the JNIOR Protocol. While the JNIOR Protocol remains a viable option for these functions the Websocket approach offers seamless integration into the dynamic web page environment. This capability is new to the Series 4 JNIOR products (Models 410, 412, and 414).
The library discussed below is designed to help you interact with the JNIOR WebSocket server easier and at a higher level. You can write the web-socket code yourself if you like.
In order to remotely control the JNIOR you need the ability to obtain I/O status and to affect changes in I/O condition. In the earlier Series 3 JNIOR this was accomplished through the JNIOR Protocol1 made available through a TCP/IP connection typically on port 9200. This is a documented binary protocol that requires special programming external to the JNIOR for its use. Care is also required to allow access to the specific port through routers and firewalls. Once successfully implemented the JNIOR Protocol not only provided I/O status and control mechanisms. It also opened access to the JNIOR Registry2 and thereby the ability to configure and manage the product.
In addition to the JNIOR Protocol it was also necessary to access the JNIOR Command Line through Telnet. Care again is required to allow access to the Telnet port (Port 23) through routers and firewalls. The Command Line is also accessible using a serial connection to the RS-232 port on the JNIOR. This Console connection provides tools for monitoring I/O status and affecting I/O conditions as well as use of various kinds of diagnostics. Furthermore in this environment the product can be fully configured in all aspects including the network parameters. In addition this is where application programs can be executed which extend the functionality of the JNIOR product.
Management of the JNIOR also requires the manipulation of files in the local file system. While files may be manipulated through Console connection transfer to/from an external system is done using FTP. Again care must be taken to allow access to the FTP command port (Port 21) through routers and firewalls. FTP typically opens/accepts data connections which must also be accommodated by the network.
Most computer languages today accommodate programmatic connection to Web Servers in one fashion or another. It makes sense since the majority of applications developed today involve networking and therefore access to the vast range of data available through Internet. These web application needed some form of bi-directional communication between the client and server. For a time programmers attempted to get the job done through an abuse of the HTTP Protocol. A simpler solution has been provided in the form or a Websocket API4 which has been quickly accommodated. As a result most web-based programming environments support Websocket connections and the programmer can utilize them as easy as any other web protocol.
Briefly, the client makes a connection to a JANOS Web Server port. This port expects a valid HTTP connection but is also shared by the Websocket protocol. Transparently behind the scenes the connection issues the appropriate HTTP headers requesting an ‘upgrade’ to the Websocket protocol. When the handshake is complete the connection will be ready to handle bi-directional websocket messaging. The JANOS Web Server supports a built-in websocket service with messaging that can be used to monitor, control and manage the Series 4 JNIOR. The built-in service employ JSON5 message formatting.
To provide additional flexibility the JANOS Websocket connection can, through a parameter in the URL, be redirected to an application running on the JNIOR. In the case websocket messages are routed through the JANOS inter-process messaging mechanism to the application program. The program uses the same messaging system to provide replies and messages outward through the websocket connection. In this fashion a completely custom messaging system can be implemented.
Any protocol providing control and management functions must employ some form of security preventing unauthorized access and disturbance. In addition to being available through a TLS/SSL secure connection the built-in JANOS Websocket implementation requires authentication. The authentication handshake must be successfully completed before any operations for monitoring, control and management will be allowed. This login uses active JANOS user accounts and subsequent operations adhere to the account permissions assigned by the administrator.
To facility the seamless use of the Websocket protocol in the implementation of dynamic web pages a mechanism is provided that utilizes any website authentication completed by the browser to pre-authorize the websocket connection. This insures that only a single entry of login credentials is required to bring up a fully functional and secure dynamic website served by the JNIOR. Note that custom application running on the JNIOR that serve websocket connections are free to implement or ignore any kind of authentication requirement.