WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

The HTTP tunnel uses a websocket for bi-directional communication between NKP client and server. The client side of the tunnel instantiates a websocket client using the HTTP libraries provided by the urn:org:netkernel:tpt:http module. The server side of the tunnel requires connection to an existing HTTP server. This is described in more detail below.

Client-side tunnel

<accessor>
  <prototype>NKPClient</prototype>
  <config>
    <tunnel factory="com.ten60.netkernel.nkp.http.HTTPNKPTunnelFactory">
      <url>ws://localhost:8084/dtest/nkp/wsEndpoint</url>
      <maxIdleTimeOut>30000</maxIdleTimeOut>
    </tunnel>
  </config>
</accessor>

Supported configuration options are:

  • url - mandatory URL of serverside endpoint to handle messages. This may be ws or wss scheme.
  • maxIdleTimeOut - optional configuration of timeout in milliseconds to close websocket if no messages are sent

Server-side tunnel

The server-side tunnel doesn't instantiate it's own HTTP server, rather it allows you connect it to a pre-existing HTTP server. This allows flexibility to combine several discrete NKP tunnels and any additional functionality onto a single port. To route websockets from an existing HTTP server you need to bind the tunnel to an ROC endpoint which will accept connections on the appropriate path and then import this endpoint into the fulcrum of an existing HTTP transport fulcrum. A prototype NKPWebsocketEndpoint is provided which handles the websocket and passes it to a corresponding tunnel configured with the same transportId. See the following example:

<space>
  <literal uri="res:/etc/system/SimpleDynamicImportHook.xml" type="xml">
    <connection>
      <type>HTTPFulcrum</type>
    </connection>
  </literal>
  <endpoint>
    <prototype>NKPWebsocketEndpoint</prototype>
    <transportId>myNKPWebsocketEndpoint</transportId>
    <grammar>
      <active>
        <identifier>ws:/path/wsEndpoint</identifier>
        <argument name="socketid" min="0" max="1" />
        <argument name="status" min="0" max="1" />
        <argument name="reason" min="0" max="1" />
      </active>
    </grammar>
  </endpoint>
  <transport>
    <prototype>NKPServer</prototype>
    <config>
      <tunnel factory="com.ten60.netkernel.nkp.http.HTTPNKPTunnelFactory">
        <transportId>myNKPWebsocketEndpoint</transportId>
      </tunnel>
    </config>
  </transport>
</space>

Supported configuration options are:

  • transportId - mandatory id which connects an instance of NKPWebsocketEndpoint to this tunnel.