The network gateway is a key network communication component of Starcounter. The
scnetworkgateway.exeprocess, which is separated from the database, represents the network gateway. It handles all external communications with the code-host, as well as communication between different code-hosts on one machine.
The gateway process talks to the codehost process (sccode) through shared memory. The same way codehost process is also separated from database process (scdata) and talks to it through shared memory. There is no direct connection between gateway and scdata, only through sccode. Network gateway parses network traffic, and prepares "messages" that are delivered to sccode through shared memory and executed there. The responses from sccode go back through the same shared memory to gateway, which sends them outside.
Detailed network gateway configuration and statistics can be retrieved using
GET /gw/statson system port (by default 8181).
Network gateway is configured in
scnetworkgateway.xml, which is located in the server repository (e.g User/Documents/Starcounter/Personal). Here are some notable configuration options:
Is the number of gateway worker threads. Normally this value should be 1-2. On high loads, this value can be increased.
Is the maximum number of connection per each gateway worker. Connections are equally distributed between workers.
Is the maximum size of incoming HTTP body/content, in bytes. Requests with bigger bodies are rejected with
413 Request Entity Too Largeand closure of TCP connection.
Is the inactive HTTP connections life time in seconds. Inactive connections are those on which send/receive are not performed.
Since the network gateway supports limited size uploads, the user has to write a custom big-data uploader for both HTTP and WebSocket protocols.
Starcounter gateway provides basic reverse proxy functionality based on HTTP Host header in requests. Reverse proxies are defined in
ReverseProxiessection of gateway configuration. Here is an example of reverse proxy that redirects all incoming HTTP requests on port 80, with Host header equals "www.example1.sc", to service on localhost and port 8080:
- DestinationIP: IP address of destination server, to which proxied requests are redirected.or
- DestinationDNS: DNS name of destination server, to which proxied requests are redirected.
- DestinationPort: port address of destination service.
- StarcounterProxyPort: Starcounter gateway port on which requests that should be proxied are received.
- MatchingHost: HTTP Host header value to filter out requests to be processed by this proxy.
In the example above when HTTP request with
www.example1.sccomes on port 80 its automatically transferred to port 8080 on localhost.
You can see current configuration for reverse proxies by calling
GET /gw/statson system port.
To apply current gateway configuration (URI aliases and reverse proxy configuration) from
scnetworkgateway.xmlone should call
GET /gw/updateconfon system port. If errors occur applying new changes - the previous configuration is kept.