Coder Social home page Coder Social logo

long-live-conn's Introduction

long-live-conn

A client and server written in Golang that can maintain a long-lived HTTP2 connection. The TCP keep-alive intervals are configurable and can be disabled. The server and client can be deployed using Docker or Kubernetes.

Deployment

A few notes on the deployment of the server and client.

Docker

This repo includes a docker-compose file that can be used to deploy the server and client. Use the make local-up command to launch the server and client. This will auto-create TLS certificates that are required for the server.

The images are available on Docker Hub:

dariomader/long-live-connection-server:v0.0.3
dariomader/long-live-connection-client:v0.0.3

Kubernetes

This repo includes k8s manifests under the install/kubernetes directory. Use the make k8s-up command to deploy the server and client to a k8s cluster. This will auto-create TLS certificates that are required for the server.

Client

  • CLIENT_KEEP_ALIVE_INTERVAL_SECONDS - The interval in seconds between keep alives. Default is 15 by the net/dialer package.
  • CLIENT_KEEP_ALIVE_ENABLED - Enables keep alives in the client. If the server has keep alives enabled, the client will not send keep alives. Default is true
  • CLIENT_TLS_DISABLE_VERIFICATION - Disables TLS verification. Default is true
  • CLIENT_REQUEST_INTERVAL_SECONDS - The interval in seconds between requests. Default is 30 seconds
  • CLIENT_SERVER_URL - The URL of the server to connect to. Default is http://localhost:8080

Server

  • SERVER_KEEP_ALIVE_ENABLED - Enables keep alives in the server. Default is true
  • SERVER_KEEP_ALIVE_INTERVAL_SECONDS - The interval in seconds between keep alives. Default is 15 by the net/TCPConn package.
  • SERVER_TLS_CERT_PATH - The path to the TLS certificate. Default is cert.pem
  • SERVER_TLS_KEY_PATH - The path to the TLS key. Default is server.key

Example Wireshark captures

This section lists some examples and their corresponding Wireshark captures.

Keep alive by the server

This requires no change in the config, it's the default.

Keep alive active and done by the server

Note: that the Wireshark traces were taken on MacOS. The default TCP keep-alive in Go is 15 seconds. If you disable the TCP keep alive in the client via CLIENT_KEEP_ALIVE_ENABLED, the client will send a RST packet directly after sending the HTTP request. In this case the client will not receive a TCP keep alive packet from the server. See below image for an example.

Keep alive disabled in the client

Keep alive by the client

To disable keep alives in the server, set ENV SERVER_KEEP_ALIVE_ENABLED to false. In this case the client will send keep alives.

Keep alive active and done by the client

long-live-conn's People

Contributors

darox avatar

Stargazers

Tomasz Tarczynski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.