GreenLightning
  • GreenLightning
  • Chapter 0: What is Green Lightning?
    • Downloads
    • FAQs
    • Benchmarks
  • Chapter 1: Getting Started with GreenLightning
    • What you need
    • Simple REST Server
      • Getting Started
      • Structures and Fields
      • Saying Hello
      • Posting and Responding with JSON
    • Comprehensive Start Guide
  • Chapter 2: Configuration
    • HTTP Configuration
    • MQTT Configuration
    • TLS Certificates
  • Chapter 3: Listeners and Behaviors
    • Default Listeners
    • Blocking Behaviors
  • Chapter 4: Routes
    • Basic Routing
  • Chapter 5: PubSub
    • Publish & Subscribe
  • Chapter 6: Clients
    • HTTP Client
    • MQTT Client
Powered by GitBook
On this page
  • Configurations
  • setHost(String host)
  • useInsecureServer()
  • setTLS(TLSCertificates tlsCertificates)
  • setClientAuthRequired(boolean b)
  • setConcurrentChannelsPerDecryptUnit(int i)
  • setConcurrentChannelsPerEncryptUnit(int i)
  • setDecryptionUnitsPerTrack(int i)
  • setEncryptionUnitsPerTrack(int i)
  • setMaxResponseSize(int i)
  • setServiceName(String name)
  • setDefaultPath(String path)
  • logTraffic(boolean b)
  • setTracks(int t)
  • setMaxConnectionBits(int i)
  • setMinConnections(int i)
  1. Chapter 2: Configuration

HTTP Configuration

To create a custom HTTP configuration, use the following code inside declareConfiguration of your GreenApp:

int port = 8000;
builder.useHTTP1xServer(port);

You can add more configurations by appending them to the last configuration:

int port = 8000;
builder.useHTTP1xServer(port)
        .useInsecureServer(); //example adding insecure server (no TLS)

Configurations

setHost(String host)

Specify a custom host address for the server.

Support "*" for subnets is enabled, for example "10.*.*.*"

builder.useHTTP1xServer(port)
        .setHost("127.0.0.1");

useInsecureServer()

Disable TLS (HTTPS) for this server.

builder.useHTTP1xServer(port)
        .useInsecureServer();

setTLS(TLSCertificates tlsCertificates)

builder.useHTTP1xServer(port)
        .setTLS(new TLSCertificate() {
                    ...
        }); 

setClientAuthRequired(boolean b)

Determines if the client requires correct certificates to be allowed to connect to server.

builder.useHTTP1xServer(port)        
        .setClientAuthRequired(true);

setConcurrentChannelsPerDecryptUnit(int i)

The number of simultaneous stream of decryption for TLS.

builder.useHTTP1xServer(port)
        .setConcurrentChannelsPerDecryptUnit(4);

setConcurrentChannelsPerEncryptUnit(int i)

The number of simultaneous stream of encryption for TLS.

builder.useHTTP1xServer(port)
        .setConcurrentChannelsPerEncryptUnit(4);

setDecryptionUnitsPerTrack(int i)

The number of decryption unit required per track. Adjust this higher if e.g. users are sending large files per track.

builder.useHTTP1xServer(port)
        .setDecryptionUnitsPerTrack(4);

setEncryptionUnitsPerTrack(int i)

The number of encryption unit required per track. Adjust this higher if more encrypted content is required.

builder.useHTTP1xServer(port)
        .setEncryptionUnitsPerTrack(4);

setMaxResponseSize(int i)

The largest response size allowed (in bytes).

builder.useHTTP1xServer(port)
        .setMaxResponseSize(1 << 20); //1 MB

setServiceName(String name)

Updates the telemetry graph for debugging purposes.

builder.useHTTP1xServer(port)
        .setServiceName("TestingServer");

setDefaultPath(String path)

Set the default relative file path (not folder!) to be served by default (i.e. user connects to 'http://localhost/');

builder.useHTTP1xServer(port)
        .setDefaultPath("site.html");

logTraffic(boolean b)

Determines if all requests AND responses should be logged.

builder.useHTTP1xServer(port)    
    .logTraffic(true);

setTracks(int t)

The number of parallel tracks for multicore performance.

builder.useHTTP1xServer(port)
        .setTracks(4);

setMaxConnectionBits(int i)

The number of max connection bits. For example, 12 would be 1 << 12 = 4096 total connections.

builder.useHTTP1xServer(port)
        .setMaxConnectionBits(12);

setMinConnections(int i)

The number of maximum users that can be reasonable expected. It will be rounded down or up if necessary to be a power of 2.

builder.useHTTP1xServer(port)        
        .setMinConnections(1000);

​

PreviousChapter 2: ConfigurationNextMQTT Configuration

Last updated 6 years ago

Set a custom TLS certificate object for HTTPS. See for more information about default TLS certificates.

here