Configuring Multiple Services on the Same Host and Port

Typically, for a network connection, you configure an IP address or configure a DNS hostname that is resolved to an IP address, and a port. For example:

Note: This documentation uses a running example with the URI scheme: ws://example.com:80/remoteService1 to demonstrate Gateway configurations.

<service>
  <accept>ws://example.com:80/</accept>
  ...
</service>

In the example, the Gateway creates a socket for port 80 on the IP address resolved by the hostname example.com and listens for requests. Typically, the Gateway binds to (and listens on) only one socket for a given IP address and port. However, you can configure the Gateway for multiple services to the same host and port. For example, you can configure similar services to use the same IP address and port number to organize multiple connection requests on the same server as the Gateway and avoid conflicts.

You configure multiple services by specifying a unique path in the URI of accept or connect elements. The Gateway, listening for all of these requests, can determine which service a request is targeting based on the combination of the scheme, host, port, and path.

Our configuration example configures the following two services to specify that the Gateway binds to the same URL scheme, host, and port: ws://example.com:80. However, notice that each URL specifies a unique path: remoteService1 and remoteService2.

<service>
  <accept>ws://example.com:80/remoteService1</accept>
  ...
  </service>

<service>
  <accept>ws://example.com:80/remoteService2</accept>
  ...
</service>

All inbound requests can communicate with multiple services on a specific host and port, and collisions are avoided because the requests use different paths. The example uses remoteService1 and remoteService2, but you can specify any name on the path so long as it conforms internet URL standards (RFC 3986). In fact, you may chose to tailor the path to reflect the actual function of the service.

Note: Kaazing Gateway follows the generic syntax defined for all URI schemes as defined by RFC 3986. See Documentation Conventions for more information about URI schemes with the Gateway.

The Gateway determines which of the two addresses to use when the client sends a request to connect with one of the pathnames. Thus, if a client makes a WebSocket connection to ws://example.com:80/remoteService1, then the Gateway reads the network headers and routes the request as configured by the accept in <accept>ws://example.com:80/remoteService1</accept>.

Notes

Note the following when configuring the Gateway to listen for multiple services on the same host and port:

See Also