GithubHelp home page GithubHelp logo

isabella232 / sling-org-apache-sling-connection-timeout-agent Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apache/sling-org-apache-sling-connection-timeout-agent

0.0 0.0 0.0 105 KB

Apache Sling Connection Timeout Agent

Home Page: https://sling.apache.org/

License: Apache License 2.0

Java 100.00%

sling-org-apache-sling-connection-timeout-agent's Introduction

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central License

Apache Sling HTTP timeout enforcer

This module is part of the Apache Sling project.

This module provides a java agent that uses the instrumentation API to add connect and read timeouts to connect made via HTTP or HTTPs. It only applies these timeouts if none were set explicitly.

End-user documentation can be found on the Apache Sling Website in the Connection Timeout Agent section.

Validation

In addition to running the integration tests, you can also build the project with mvn clean package and then run a simple connection test with

java -javaagent:target/org.apache.sling.connection-timeout-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=<agent-connect-timeout>,<agent-read-timeout> -cp target/test-classes:target/it-dependencies/* org.apache.sling.cta.impl.HttpClientLauncher <url> <client-type> [<client-connect-timeout> <client-read-timeout>]

The parameters are as follows:

  • <agent-connect-timeout> - connection timeout in milliseconds to apply via the agent
  • <agent-read-timeout>- read timeout in milliseconds to apply via the agent
  • <url> - the URL to access
  • <client-type> - the client type, either JavaNet for java.net.URL-based connections ,HC3 for Apache Commons HttpClient 3.x, HC4 for Apache Commons HttpClient 4.x or OkHttp for OK HTTP.
  • <client-connect-timeout> (optional) - the connection timeout in milliseconds to apply via client APIs
  • <client-read-timeout> (optional) - the read timeout in milliseconds to apply via client APIs

The read and connect timeouts may be specified for both the agent and client APIs. The reason is that the agent should not change the timeout defaults if they are already set. Therefore, setting the agent timeouts to a very high value and the client API timeouts to a very low value ( e.g. 1 millisecond ) should still result in a timeout.

For a test that always fails, set one of the timeouts to 1. Both executions listed below will typically fail:

java -javaagent:target/org.apache.sling.connection-timeout-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=1,1000 -cp target/test-classes:target/it-dependencies/* org.apache.sling.cta.impl.HttpClientLauncher https://sling.apache.org JavaNet
java -javaagent:target/org.apache.sling.connection-timeout-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=1000,1 -cp target/test-classes:target/it-dependencies/* org.apache.sling.cta.impl.HttpClientLauncher https://sling.apache.org JavaNet

In contrast, the execution below should succeed:

java -javaagent:target/org.apache.sling.connection-timeout-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=1000,1000 -cp target/test-classes:target/it-dependencies/* org.apache.sling.cta.impl.HttpClientLauncher https://sling.apache.org JavaNet

sling-org-apache-sling-connection-timeout-agent's People

Contributors

bdelacretaz avatar klcodanr avatar raducotescu avatar rombert 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.