Java client for Consul HTTP API

Overview

consul-api

Build Status

Java client for Consul HTTP API (http://consul.io)

Supports all API endpoints (http://www.consul.io/docs/agent/http.html), all consistency modes and parameters (tags, datacenters etc.)

How to use

ConsulClient client = new ConsulClient("localhost");

// set KV
byte[] binaryData = new byte[] {1,2,3,4,5,6,7};
client.setKVBinaryValue("someKey", binaryData);

client.setKVValue("com.my.app.foo", "foo");
client.setKVValue("com.my.app.bar", "bar");
client.setKVValue("com.your.app.foo", "hello");
client.setKVValue("com.your.app.bar", "world");

// get single KV for key
Response<GetValue> keyValueResponse = client.getKVValue("com.my.app.foo");
System.out.println(keyValueResponse.getValue().getKey() + ": " + keyValueResponse.getValue().getDecodedValue()); // prints "com.my.app.foo: foo"

// get list of KVs for key prefix (recursive)
Response<List<GetValue>> keyValuesResponse = client.getKVValues("com.my");
keyValuesResponse.getValue().forEach(value -> System.out.println(value.getKey() + ": " + value.getDecodedValue())); // prints "com.my.app.foo: foo" and "com.my.app.bar: bar"

//list known datacenters
Response<List<String>> response = client.getCatalogDatacenters();
System.out.println("Datacenters: " + response.getValue());

// register new service
NewService newService = new NewService();
newService.setId("myapp_01");
newService.setName("myapp");
newService.setTags(Arrays.asList("EU-West", "EU-East"));
newService.setPort(8080);
client.agentServiceRegister(newService);

// register new service with associated health check
NewService newService = new NewService();
newService.setId("myapp_02");
newService.setTags(Collections.singletonList("EU-East"));
newService.setName("myapp");
newService.setPort(8080);

NewService.Check serviceCheck = new NewService.Check();
serviceCheck.setScript("/usr/bin/some-check-script");
serviceCheck.setInterval("10s");
newService.setCheck(serviceCheck);

client.agentServiceRegister(newService);

// query for healthy services based on name (returns myapp_01 and myapp_02 if healthy)
HealthServicesRequest request = HealthServicesRequest.newBuilder()
					.setPassing(true)
					.setQueryParams(QueryParams.DEFAULT)
					.build();
Response<List<HealthService>> healthyServices = client.getHealthServices("myapp", request);

// query for healthy services based on name and tag (returns myapp_01 if healthy)
HealthServicesRequest request = HealthServicesRequest.newBuilder()
					.setTag("EU-West")
					.setPassing(true)
					.setQueryParams(QueryParams.DEFAULT)
					.build();
Response<List<HealthService>> healthyServices = client.getHealthServices("myapp", request);

How to add consul-api into your project

Gradle

compile "com.ecwid.consul:consul-api:1.4.5"

Maven

<dependency>
  <groupId>com.ecwid.consul</groupId>
  <artifactId>consul-api</artifactId>
  <version>1.4.5</version>
</dependency>

How to build from sources

  • Checkout the sources
  • ./gradlew build

Gradle will compile sources, package classes (sources and javadocs too) into jars and run all tests. The build results will located in build/libs/ folder

Comments
  • Consul 1.0.0 compatibility

    Consul 1.0.0 compatibility

    Consul 1.0.0 has some breaking API changes: https://www.consul.io/docs/upgrade-specific.html#consul-1-0

    One of them is that com.ecwid.consul.v1.agent.model.Self.Config must be broken down into two classes at least: Config and DebugConfig

    enhancement 
    opened by lazystone 13
  • Consul service not reachable. com.ecwid.consul.transport.TransportException: java.net.SocketException: Connection reset

    Consul service not reachable. com.ecwid.consul.transport.TransportException: java.net.SocketException: Connection reset

    I am trying to diagnose a problem that I don't know if it is a bug in Consul API (1.1.7) or the way I am running Consul (v 0.6). I get the following stack repeatedly in my logs. I'm using the Consul API in conjunction with a Netflix Archaius wrapper but looking at the code I'm not sure it is a bug there. Seems to be an issue with the way Consul API is trying to create a catalog client.

    2016-05-04T19:04:29,435 ERROR [net.researchgate.archaius.ConsulConfigurationSource] [pollingConfigurationSource] Consul service not reachable. i-699d84ae: com.ecwid.consul.transport.TransportException: java.net.SocketException: Connection reset
        at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:80) [consul-api-1.1.7.jar:]
        at com.ecwid.consul.transport.AbstractHttpTransport.makeGetRequest(AbstractHttpTransport.java:39) [consul-api-1.1.7.jar:]
        at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:81) [consul-api-1.1.7.jar:]
        at com.ecwid.consul.v1.catalog.CatalogConsulClient.getCatalogService(CatalogConsulClient.java:129) [consul-api-1.1.7.jar:]
        at com.ecwid.consul.v1.catalog.CatalogConsulClient.getCatalogService(CatalogConsulClient.java:122) [consul-api-1.1.7.jar:]
        at com.ecwid.consul.v1.ConsulClient.getCatalogService(ConsulClient.java:284) [consul-api-1.1.7.jar:]
        at net.researchgate.archaius.ConsulConfigurationSource.setClient(ConsulConfigurationSource.java:82) [archaius-consul-0.1.2.jar:]
        at net.researchgate.archaius.ConsulConfigurationSource.poll(ConsulConfigurationSource.java:66) [archaius-consul-0.1.2.jar:]
        at com.netflix.config.AbstractPollingScheduler$1.run(AbstractPollingScheduler.java:163) [archaius-core-0.7.3.jar:0.7.3]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_72-internal]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [rt.jar:1.8.0_72-internal]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [rt.jar:1.8.0_72-internal]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [rt.jar:1.8.0_72-internal]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_72-internal]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_72-internal]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_72-internal]
    Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:209) [rt.jar:1.8.0_72-internal]
        at java.net.SocketInputStream.read(SocketInputStream.java:141) [rt.jar:1.8.0_72-internal]
        at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:160) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:84) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:273) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.impl.conn.LoggingSessionInputBuffer.readLine(LoggingSessionInputBuffer.java:116) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:283) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:251) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:197) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123) [httpcore-4.3.3.jar:4.3.3]
        at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:685) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:487) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:214) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:160) [httpclient-4.3.6.jar:4.3.6]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:136) [httpclient-4.3.6.jar:4.3.6]
        at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:64) [consul-api-1.1.7.jar:]
    

    Followed by 2 Apache http error messages:

    Retrying request to {}->http://172.31.2.106:8300
    I/O exception (java.net.SocketException) caught when processing request to {}->http://172.31.2.106:8300: Connection reset
    

    A lot of Googling shows similar errors with connection reset on port 8300 saying that the client should be trying to connect to 8301 instead. Is this some problem in the way I have Consul configured or is this a bug in the Consul client?

    Thanks!

    opened by jhovell 11
  • how to connect a consul cluster?

    how to connect a consul cluster?

    the api is as follows: ConsulClient client = new ConsulClient("localhost"); if the "localhost" died,the client will be died too? is there any other way like 1ip:8500,2ip:8500,2ip:8500 to prevent single point failure?

    opened by Jaware 9
  • No enum constant

    No enum constant

    version:1.2.1 log: Caused by: java.lang.IllegalArgumentException: No enum constant com.ecwid.consul.v1.health.model.Check.CheckStatus.passing at java.lang.Enum.valueOf(Enum.java:238) at com.google.gson.DefaultTypeAdapters$EnumTypeAdapter.deserialize(DefaultTypeAdapters.java:410) at com.google.gson.DefaultTypeAdapters$EnumTypeAdapter.deserialize(DefaultTypeAdapters.java:400) at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:50)

    opened by longshang 9
  • Cannot register script health check on service

    Cannot register script health check on service

    Hello to everyone,

    I am using the current library (1.4.1) as a maven dependency, also I am using consul version 1.3. But I cannot register script Health check on service.

    My code was working on consul version 1.0.7, and using the library version 1.4.0

            NewService.Check serviceCheck = new NewService.Check();
            serviceCheck.setScript("docker exec mysql  mysqladmin -uroot -pxUNvbFUbHvv6hnkrTg86g7fXe87W9fTg status");
            serviceCheck.setInterval("30s");
    

    But now I am getting

    Exception in thread "main" OperationException{statusCode=400, statusMessage='Bad Request', statusContent='Invalid check: TTL must be > 0 for TTL checks'}
    	at com.ecwid.consul.v1.agent.AgentConsulClient.agentServiceRegister(AgentConsulClient.java:278)
    	at com.ecwid.consul.v1.agent.AgentConsulClient.agentServiceRegister(AgentConsulClient.java:265)
    	at com.ecwid.consul.v1.ConsulClient.agentServiceRegister(ConsulClient.java:304)
    	at eu.orchestrator.agent.Agent.checkIfContainerServiceRunning(Agent.java:838)
    	at eu.orchestrator.agent.Agent.phase6(Agent.java:296)
    	at eu.orchestrator.agent.Agent.bootAgent(Agent.java:84)
    	at eu.orchestrator.agent.Agent.main(Agent.java:69)
    
    opened by pparthenhs 7
  • Java 9 incompatibility

    Java 9 incompatibility

    Seems like library is not java 9 compatible:

    java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    	at com.ecwid.consul.v1.kv.model.GetValue.getDecodedValue(GetValue.java:99) ~[consul-api-1.3.0.jar!/:?]
    	at com.ecwid.consul.v1.kv.model.GetValue.getDecodedValue(GetValue.java:103) ~[consul-api-1.3.0.jar!/:?]
    	at org.springframework.cloud.consul.config.ConsulPropertySource.parsePropertiesInKeyValueFormat(ConsulPropertySource.java:102) ~[spring-cloud-consul-config-2.0.0.M4.jar!/:2.0.0.M4]
    	at org.springframework.cloud.consul.config.ConsulPropertySource.init(ConsulPropertySource.java:75) ~[spring-cloud-consul-config-2.0.0.M4.jar!/:2.0.0.M4]
    	at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.create(ConsulPropertySourceLocator.java:155) ~[spring-cloud-consul-config-2.0.0.M4.jar!/:2.0.0.M4]
    	at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:129) ~[spring-cloud-consul-config-2.0.0.M4.jar!/:2.0.0.M4]
    	at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94) ~[spring-cloud-context-2.0.0.M5.jar!/:2.0.0.M5]
    	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:626) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
    	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:366) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
    	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:136) ~[spring-boot-2.0.0.RC1.jar!/:2.0.0.RC1]
    	at com.cabonline.order.Runner.main(Runner.java:15) ~[classes!/:?]
    	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
    	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[order-service-622.jar:?]
    	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[order-service-622.jar:?]
    	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[order-service-622.jar:?]
    	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[order-service-622.jar:?]
    Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
    

    Since it's used by spring-cloud-consul project which suppose to run under Java 9 then it would be nice to fix this.

    opened by lazystone 7
  • 2-way SSL from Spring to Consul fails. (Keystore is not being read)

    2-way SSL from Spring to Consul fails. (Keystore is not being read)

    We have a very simple application. All it does is read KVs from Consul. During SSL handshake, the client fails to send the client certificate resulting in bad certificate error. What we found was that ID keystore specified in command line JVM param -Djavax.net.ssl.keyStore was not being read. Appears to be a bug in the library. While debugging through the code, we saw that Spring Consul library is using deprecated classes of http client. Is that the reason we are seeing this issue?

    Here is the code. We have a single file.

    com.test.TestApp.java;

    package com.test;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.autoconfigure.web.ServerProperties;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.ComponentScan;
    
    
    /**
     * Main Spring Boot Application class for
     * the TestApp Consul implementation.
     */
    @SpringBootApplication
    public class TestApp {
    
        public static void main(String[] args) {
            SpringApplication app = new SpringApplication( TestApp.class );
            app.run( args );
        }
    
    }
    

    Here is the gradle build file:

    buildscript {
        ext {
            springBootVersion = '1.3.5.RELEASE'
        }
        repositories {
            mavenLocal()
            maven { url "http://artifactory:8081/artifactory/repo" }
            mavenCentral()
            maven { url "http://repo.spring.io/libs-release" }
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
            classpath('io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE')
        }
    }
    
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'spring-boot' 
    apply plugin: 'io.spring.dependency-management' 
    
    jar {
        baseName = 'TestApp'
        version = '1.0.3'
    }
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    
    repositories {
        mavenLocal()
        maven { url "http://artifactory:8081/artifactory/repo" }
        mavenCentral()
        maven { url "http://repo.spring.io/libs-release" }
        maven { url "http://repo.spring.io/libs-milestone" }
    }
    
    dependencies {
        compile('org.springframework.boot:spring-boot-starter-actuator')
        compile('org.springframework.boot:spring-boot-configuration-processor')
        compile('org.springframework.cloud:spring-cloud-starter-consul-all')
        testCompile('org.springframework.boot:spring-boot-starter-test') 
        testCompile('org.mockito:mockito-all:1.10.19')
    }
    
    dependencyManagement {
        imports { 
            mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.SR5" 
            mavenBom "org.springframework.cloud:spring-cloud-consul-dependencies:1.0.2.RELEASE" 
        }
    }
    
    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }
    artifacts {
        archives sourcesJar
    }
    
    eclipse {
        classpath {
             containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
             containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
        }
    }
    
    task wrapper(type: Wrapper) {
        gradleVersion = '2.14'
    }
    
    def filesToCopy = copySpec {
        from 'build/libs/'
        include '*SHOT.jar'
    }
    

    Here is the log file contents with SSL debug enabled:

    2016-08-30 13:35:51.292  INFO 34035 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@608416bd: startup date [Tue Aug 30 13:35:51 CDT 2016]; root of context hierarchy
    2016-08-30 13:35:52.023  INFO 34035 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    2016-08-30 13:35:52.107  INFO 34035 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$4dc2a8d4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    trustStore is: /<REDACTED>
    trustStore type is : jks
    trustStore provider is :
    init truststore
    adding as trusted cert:
    <REDACTED>
    trigger seeding of SecureRandom
    done seeding SecureRandom
    
      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v1.3.5.RELEASE)
    
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
    Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
    Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
    main, setSoTimeout(60000) called
    Allow unsafe renegotiation: false
    Allow legacy hello messages: true
    Is initial handshake: true
    Is secure renegotiation: false
    Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 for TLSv1
    Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 for TLSv1
    Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 for TLSv1
    Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 for TLSv1.1
    Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 for TLSv1.1
    Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 for TLSv1.1
    %% No cached client session
    *** ClientHello, TLSv1.2
    RandomCookie:  GMT: 1455739401 bytes = { 131, 144, 62, 92, 121, 62, 206, 192, 62, 91, 69, 244, 64, 45, 201, 1, 95, 138, 111, 228, 1, 200, 50, 90, 207, 86, 60, 197 }
    Session ID:  {}
    Cipher Suites: [TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
    Compression Methods:  { 0 }
    Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA224withECDSA, SHA224withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
    ***
    [write] MD5 and SHA1 hashes:  len = 117
    0000: 01 00 00 71 03 03 57 C5   D2 09 83 90 3E 5C 79 3E  ...q..W.....>\y>
    0010: CE C0 3E 5B 45 F4 40 2D   C9 01 5F 8A 6F E4 01 C8  ..>[E.@-.._.o...
    0020: 32 5A CF 56 3C C5 00 00   2C 00 3D 00 6B 00 6A 00  2Z.V<...,.=.k.j.
    0030: 35 00 39 00 38 00 3C 00   67 00 40 00 2F 00 33 00  5.9.8.<.g.@./.3.
    0040: 32 00 9D 00 9F 00 A3 00   9C 00 9E 00 A2 00 0A 00  2...............
    0050: 16 00 13 00 FF 01 00 00   1C 00 0D 00 18 00 16 06  ................
    0060: 03 06 01 05 03 05 01 04   03 04 01 03 03 03 01 02  ................
    0070: 03 02 01 02 02                                     .....
    main, WRITE: TLSv1.2 Handshake, length = 117
    [Raw write]: length = 122
    0000: 16 03 03 00 75 01 00 00   71 03 03 57 C5 D2 09 83  ....u...q..W....
    0010: 90 3E 5C 79 3E CE C0 3E   5B 45 F4 40 2D C9 01 5F  .>\y>..>[E.@-.._
    0020: 8A 6F E4 01 C8 32 5A CF   56 3C C5 00 00 2C 00 3D  .o...2Z.V<...,.=
    0030: 00 6B 00 6A 00 35 00 39   00 38 00 3C 00 67 00 40  .k.j.5.9.8.<.g.@
    0040: 00 2F 00 33 00 32 00 9D   00 9F 00 A3 00 9C 00 9E  ./.3.2..........
    0050: 00 A2 00 0A 00 16 00 13   00 FF 01 00 00 1C 00 0D  ................
    0060: 00 18 00 16 06 03 06 01   05 03 05 01 04 03 04 01  ................
    0070: 03 03 03 01 02 03 02 01   02 02                    ..........
    [Raw read]: length = 5
    0000: 16 03 03 00 31                                     ....1
    [Raw read]: length = 49
    0000: 02 00 00 2D 03 03 33 39   BD CB CE 4B E2 D5 30 19  ...-..39...K..0.
    0010: 56 D9 F3 E4 BC 67 D2 C6   A6 90 23 0F 58 CF 2D FF  V....g....#.X.-.
    0020: E3 18 17 5C A8 13 00 00   35 00 00 05 FF 01 00 01  ...\....5.......
    0030: 00                                                 .
    main, READ: TLSv1.2 Handshake, length = 49
    *** ServerHello, TLSv1.2
    RandomCookie:  GMT: 859356363 bytes = { 206, 75, 226, 213, 48, 25, 86, 217, 243, 228, 188, 103, 210, 198, 166, 144, 35, 15, 88, 207, 45, 255, 227, 24, 23, 92, 168, 19 }
    Session ID:  {}
    Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA
    Compression Method: 0
    Extension renegotiation_info, renegotiated_connection: <empty>
    ***
    %% Initialized:  [Session-1, TLS_RSA_WITH_AES_256_CBC_SHA]
    ** TLS_RSA_WITH_AES_256_CBC_SHA
    [read] MD5 and SHA1 hashes:  len = 49
    0000: 02 00 00 2D 03 03 33 39   BD CB CE 4B E2 D5 30 19  ...-..39...K..0.
    0010: 56 D9 F3 E4 BC 67 D2 C6   A6 90 23 0F 58 CF 2D FF  V....g....#.X.-.
    0020: E3 18 17 5C A8 13 00 00   35 00 00 05 FF 01 00 01  ...\....5.......
    0030: 00                                                 .
    [Raw read]: length = 5
    0000: 16 03 03 09 3B                                     ....;
    [Raw read]: length = 2363
    <REDACTED>
    main, READ: TLSv1.2 Handshake, length = 2363
    *** Certificate chain
    chain [0] = [
    <REDACTED>
    ]
      Algorithm: [SHA256withRSA]
      Signature:
    ]
    chain [1] = [
    [
    <REDACTED>
    ]
    
    ]
      Algorithm: [SHA1withRSA]
      Signature:
    <REDACTED>
    ]
    ***
    Found trusted certificate:
    [
    [
    REDACTED]
    ]
    
    ]
      Algorithm: [SHA1withRSA]
      Signature:
    REDACTED
    ]
    [read] MD5 and SHA1 hashes:  len = 2363
    REDACTED
    [Raw read]: length = 5
    REDACTED
    [Raw read]: length = 97
    REDACTED
    
    main, READ: TLSv1.2 Handshake, length = 97
    *** CertificateRequest
    Cert Types: RSA, ECDSA
    Supported Signature Algorithms: SHA256withRSA, SHA256withECDSA, SHA384withRSA, SHA384withECDSA, SHA1withRSA, SHA1withECDSA
    Cert Authorities:
    REDACTED
    [read] MD5 and SHA1 hashes:  len = 97
    REDACTED
    [Raw read]: length = 5
    REDACTED
    [Raw read]: length = 4
    REDACTED
    main, READ: TLSv1.2 Handshake, length = 4
    *** ServerHelloDone
    [read] MD5 and SHA1 hashes:  len = 4
    0000: 0E 00 00 00                                        ....
    Warning: no suitable certificate found - continuing without client authentication
    *** Certificate chain
    <Empty>
    ***
    *** ClientKeyExchange, RSA PreMasterSecret, TLSv1.2
    [write] MD5 and SHA1 hashes:  len = 269
    REDACTED
    main, WRITE: TLSv1.2 Handshake, length = 269
    [Raw write]: length = 274
    REDACTED
    SESSION KEYGEN:
    PreMaster Secret:
    REDACTED
    CONNECTION KEYGEN:
    Client Nonce:
    REDACTED
    Server Nonce:
    REDACTED
    Master Secret:
    REDACTED
    Client MAC write Secret:
    REDACTED
    Server MAC write Secret:
    REDACTED
    Client write key:
    REDACTED
    Server write key:
    REDACTED
    ... no IV derived for this protocol
    main, WRITE: TLSv1.2 Change Cipher Spec, length = 1
    [Raw write]: length = 6
    0000: 14 03 03 00 01 01                                  ......
    *** Finished
    verify_data:  { 3, 113, 121, 151, 216, 225, 246, 250, 255, 32, 107, 196 }
    ***
    [write] MD5 and SHA1 hashes:  len = 16
    REDACTED
    Padded plaintext before ENCRYPTION:  len = 64
    REDACTED
    main, WRITE: TLSv1.2 Handshake, length = 64
    main, waiting for close_notify or alert: state 1
    [Raw read]: length = 5
    0000: 15 03 03 00 02                                     .....
    [Raw read]: length = 2
    0000: 02 2A                                              .*
    main, READ: TLSv1.2 Alert, length = 2
    main, RECV TLSv1.2 ALERT:  fatal, bad_certificate
    %% Invalidated:  [Session-1, TLS_RSA_WITH_AES_256_CBC_SHA]
    main, called closeSocket()
    main, Exception while waiting for close javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
    main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
    main, called close()
    main, called closeInternal(true)
    2016-08-30 13:35:53.922 ERROR 34035 --- [           main] o.s.c.c.c.ConsulPropertySourceLocator    : Fail fast is set and there was an error reading configuration from consul.
    2016-08-30 13:35:53.925 ERROR 34035 --- [           main] o.s.boot.SpringApplication               : Application startup failed
    
    com.ecwid.consul.transport.TransportException: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
            at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:91) ~[consul-api-1.1.10.jar!/:na]
            at com.ecwid.consul.transport.AbstractHttpTransport.makeGetRequest(AbstractHttpTransport.java:50) ~[consul-api-1.1.10.jar!/:na]
            at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:81) ~[consul-api-1.1.10.jar!/:na]
            at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:150) ~[consul-api-1.1.10.jar!/:na]
            at com.ecwid.consul.v1.ConsulClient.getKVValues(ConsulClient.java:404) ~[consul-api-1.1.10.jar!/:na]
            at org.springframework.cloud.consul.config.ConsulPropertySource.init(ConsulPropertySource.java:64) ~[spring-cloud-consul-config-1.0.2.RELEASE.jar!/:1.0.2.RELEASE]
            at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.create(ConsulPropertySourceLocator.java:135) ~[spring-cloud-consul-config-1.0.2.RELEASE.jar!/:1.0.2.RELEASE]
            at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:113) ~[spring-cloud-consul-config-1.0.2.RELEASE.jar!/:1.0.2.RELEASE]
            at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89) ~[spring-cloud-context-1.1.0.RELEASE.jar!/:1.1.0.RELEASE]
            at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:640) ~[spring-boot-1.3.5.RELEASE.jar!/:1.3.5.RELEASE]
            at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:343) ~[spring-boot-1.3.5.RELEASE.jar!/:1.3.5.RELEASE]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-1.3.5.RELEASE.jar!/:1.3.5.RELEASE]
            at com.test.TestApp.main(TestApp.java:23) [TestApp-1.0.3.jar!/:na]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
            at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54) [TestApp-1.0.3.jar!/:na]
            at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
            at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_101]
            at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1769) ~[na:1.8.0_101]
            at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124) ~[na:1.8.0_101]
            at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:1083) ~[na:1.8.0_101]
            at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1222) ~[na:1.8.0_101]
            at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1134) ~[na:1.8.0_101]
            at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348) ~[na:1.8.0_101]
            at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) ~[na:1.8.0_101]
            at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) ~[na:1.8.0_101]
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) ~[na:1.8.0_101]
            at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:543) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:409) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) ~[httpclient-4.5.jar!/:4.5]
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139) ~[httpclient-4.5.jar!/:4.5]
            at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:75) ~[consul-api-1.1.10.jar!/:na]
            ... 18 common frames omitted
    
    2016-08-30 13:35:53.938  INFO 34035 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [jar:file:REDACTED, jar:file:REDACTED/]
    Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
            at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
            ... 1 more
    Caused by: com.ecwid.consul.transport.TransportException: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
            at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:91)
            at com.ecwid.consul.transport.AbstractHttpTransport.makeGetRequest(AbstractHttpTransport.java:50)
            at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:81)
            at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:150)
            at com.ecwid.consul.v1.ConsulClient.getKVValues(ConsulClient.java:404)
            at org.springframework.cloud.consul.config.ConsulPropertySource.init(ConsulPropertySource.java:64)
            at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.create(ConsulPropertySourceLocator.java:135)
            at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:113)
            at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89)
            at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:640)
            at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:343)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
            at com.test.TestApp.main(TestApp.java:23)
            ... 6 more
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
            at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
            at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
            at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
            at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
            at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1769)
            at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124)
            at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:1083)
            at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1222)
            at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1134)
            at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
            at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
            at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
            at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
            at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
            at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:543)
            at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:409)
            at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
            at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
            at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
            at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
            at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
            at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:75)
            ... 18 more
    
    enhancement 
    opened by rogerhill01234 7
  • Add support for deregisterCriticalServiceAfter

    Add support for deregisterCriticalServiceAfter

    Consul 7.0 adds support for DeregisterCriticalServiceAfter. Based on the Gson serialization of NewService, this is all that should be required.

    See https://github.com/Ecwid/consul-api/issues/64

    opened by dwelch2344 7
  • Consul 1.0.0 / Consul Api(jar) 1.2.4 wrong http method for agentCheckPass

    Consul 1.0.0 / Consul Api(jar) 1.2.4 wrong http method for agentCheckPass

    AgentConsulClient should make a PUT instead of GET

    I have tried curl with PUT and it worked

    consul log:

    2017/11/14 13:00:10 [ERR] http: Request GET /v1/agent/check/pass/service:spring-mvc-archetype-f97384782ff84dd3dc86fb6ca95dc939, error: method GET not allowed from=127.0.0.1:61048
    2017/11/14 13:00:10 [ERR] http: Request GET /v1/agent/check/pass/service:spring-mvc-archetype-585af995-d9c0-49b0-94cf-e7213f5b16f9-management, error: method GET not allowed from=127.0.0.1:61048
    

    java log:

    com.ecwid.consul.v1.OperationException: OperationException(statusCode=405, statusMessage='Method Not Allowed', statusContent='method GET not allowed')
        at com.ecwid.consul.v1.agent.AgentConsulClient.agentCheckPass(AgentConsulClient.java:197) ~[consul-api-1.2.4.jar:?]
        at com.ecwid.consul.v1.agent.AgentConsulClient.agentCheckPass(AgentConsulClient.java:186) ~[consul-api-1.2.4.jar:?]
        at com.ecwid.consul.v1.ConsulClient.agentCheckPass(ConsulClient.java:247) ~[consul-api-1.2.4.jar:?]
        at org.springframework.cloud.consul.discovery.TtlScheduler$ConsulHeartbeatTask.run(TtlScheduler.java:91) ~[spring-cloud-consul-discovery-1.2.1.RELEASE.jar:1.2.1.RELEASE]
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_144]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_144]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_144]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_144]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
    

    source:

     @Override
     public Response<Void> agentCheckPass(String checkId, String note) {
    	UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
    	RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/pass/" + checkId, noteParams);
    
    	if (rawResponse.getStatusCode() == 200) {
    		return new Response<Void>(null, rawResponse);
    	} else {
    		throw new OperationException(rawResponse);
    	}
    }
    
    bug 
    opened by radut 6
  • Consul 1.0.0 compatibility

    Consul 1.0.0 compatibility

    Fixes #130

    The most important changes are made in AgentConsulClient - some requests are PUT now instead of GET.

    Changes in build.gradle unimportant apart from embedded-consul dependency which supports Consul 1.0.0

    I tried to split Config to Config and DebugConfig but to be honest, I just don't want to add tons of debug parameters, so I just left one that existed in old Config before and removed which does not exist in the new DebugConfig.

    enhancement 
    opened by lazystone 5
  • QueryParams.toUrlParameters() should treat index as unsigned

    QueryParams.toUrlParameters() should treat index as unsigned

    If a negative (signed) long is passed in for the index, the request fails with a 400 error. Consul expects an unsigned long value instead.

    I've hit this problem in practice when I'm trying to make blocking ConsulClient.eventList() calls. The indexes I need to supply are generated from a UUID and hence often end up as a negative value when represented as a signed long.

    QueryParams.toUrlParameters() currently contains:

    params.add("index=" + index);
    

    I think it should actually be:

    params.add("index=" + Long.toUnsignedString(index));
    

    That assumes Java 8. Otherwise something like this should work for the conversion:

      private static String toUnsignedString(long l) {
        if (l > 0) {
          return Long.toString(l);
        } else {
          long quot = (l >>> 1) / 5;
          long rem = l - quot * 10;
          return Long.toString(quot) + rem;
        }
      }
    
    opened by chrismiller 5
  • AgentConsulClient.agentServiceRegister use wrong content-type

    AgentConsulClient.agentServiceRegister use wrong content-type

    AgentConsulClient.agentServiceRegister send a http request with json body,but the content-type is text/plain; charset=UTF-8 rather than application/json

    opened by FunnyYish 1
  • Adding support for connect during service registration

    Adding support for connect during service registration

    We're currently using this library to register service health checks but we're in the process of now building out a service mesh for services to communicate through. This library doesn't support the connect option during service registration (https://www.consul.io/api-docs/agent/service#connect). I've added it on a local build but wondering if there is interest for adding this to the mainline?

    opened by gtwhite 1
  • QueryParams should support recursive parameter

    QueryParams should support recursive parameter

    To delete a key and all subkeys, we need recurse parameter. see https://www.consul.io/api-docs/kv

    recurse (bool: false) - Specifies to delete all keys which have the specified prefix. Without this, only a key with an exact match will be deleted.
    
    opened by DanielYWoo 0
  • acl token support in setKVValue

    acl token support in setKVValue

    Currently the client can use an acl token, e.g.,

    	@Override
    	public Response<Boolean> setKVBinaryValue(String key, byte[] value, String token, PutParams putParams, QueryParams queryParams) {
    		Request request = Request.Builder.newBuilder()
    			.setEndpoint("/v1/kv/" + key)
    			.setToken(token) <---- here is the acl token as X-Consul-Token header
    			.addUrlParameter(queryParams)
    			.addUrlParameter(putParams)
    			.setBinaryContent(value)
    			.build();
    

    The token will be later used by Utils.createTokenMap() and attached to the request header as X-Consul-Token. Good.

    But in the string value of the same method, why do we use the token as a request parameter? And the token will not be attached to the request header, instead, it's attached as a request parameter. What is it for?

    	@Override
    	public Response<Boolean> setKVValue(String key, String value, String token, PutParams putParams, QueryParams queryParams) {
    		UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null; <-- what is this?
    		HttpResponse httpResponse = rawClient.makePutRequest("/v1/kv/" + key, value, putParams, tokenParam, queryParams);	
    
    
    opened by DanielYWoo 0
Releases(v1.4.5)
Owner
Ecwid
Ecwid
Opinionated libraries for HTTP&JSON-based RPC using Retrofit, Feign, OkHttp as clients and Jetty/Jersey as servers

Conjure Java Runtime (formerly http-remoting) This repository provides an opinionated set of libraries for defining and creating RESTish/RPC servers a

Palantir Technologies 76 Dec 13, 2022
A simplistic configuration API

Config API This is just a simple configuration API I made a while back because I needed one, code is pretty outdated. Current Supported Data Types We

null 5 Nov 21, 2021
Annotation/Reflection Based Bukkit Command API. Containing many features such as help-service, command providers, tab completion, and many more!

CommandAPI Annotation/Reflection Based Command API that just does what you want it to do without any problems. Importing Maven <repository> <id>

damt 1 Jun 13, 2022
Drone Service REST API in Spring boot

Drones Service REST API ?? START Introduction There is a major new technology that is destined to be a disruptive force in the field of transportation

Moses-K 1 Feb 4, 2022
Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main class. Supporting pure Microservice or Micro-monolith styles.

Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main class. Supporting pure Microservice or Micro-monolith styles.

AOL 936 Dec 19, 2022
[JAVA] Projeto exemplo de uma arquitetura modular em Java

Arquitetura modular O objetivo do bom design de software, como já diria Robert C. Martin, em seu livro 'Clean Architecture: A Craftsman's Guide to Sof

HelpDEV 97 Dec 29, 2022
Apache Dubbo is a high-performance, java based, open source RPC framework.

Apache Dubbo Project Apache Dubbo is a high-performance, Java-based open-source RPC framework. Please visit official site for quick start and document

The Apache Software Foundation 38.3k Jan 9, 2023
Lightweight framework for building java microservices

Ja-micro Ja-micro is a lightweight Java framework for building microservices. Introduction Ja-micro is a framework that allows developers to easily de

Sixt 621 Aug 21, 2022
WSO2 Microservices Framework for Java (MSF4J)

Build status: WSO2 Microservices Framework for Java (MSF4J) WSO2 Microservices Framework for Java (MSF4J) is a lightweight high performance framework

WSO2 359 Dec 27, 2022
Sample application demonstrating an order fulfillment system decomposed into multiple independant components (e.g. microservices). Showing concrete implementation alternatives using e.g. Java, Spring Boot, Apache Kafka, Camunda, Zeebe, ...

Sample application demonstrating an order fulfillment system decomposed into multiple independant components (e.g. microservices). Showing concrete implementation alternatives using e.g. Java, Spring Boot, Apache Kafka, Camunda, Zeebe, ...

Bernd Ruecker 1.2k Dec 14, 2022
Source Code for 'Pro Java Microservices with Quarkus and Kubernetes' by Nebrass Lamouchi

Apress Source Code This repository accompanies Pro Java Microservices with Quarkus and Kubernetes by Nebrass Lamouchi (Apress, 2021). Download the fil

Apress 24 Oct 31, 2022
Define Java service providers by annotating them directly

Annotated Service Provider Define JVM service providers by annotating the provider class directly. This annotation processor will add to the class-pat

Emily 5 Oct 31, 2021
Takin is an Java-based, open-source system designed to measure online or test environmental performance test for full-links, Especially for microservices

Takin is an Java-based, open-source system designed to measure online environmental performance test for full-links, Especially for microservices. Through Takin, middlewares and applications can identify real online traffic and test traffic, ensure that they enter the right databases.

ShulieTech 1.2k Dec 21, 2022
Spring MSA api gateway & service discovery with consul & Jaeger & Cassandra

Spring-Cloud-MSA 준비 Cassandra 서버를 준비한다 table.sql 파일로 keyspace와 테이블을 만들어 둔다 Consul 1.11.1버전 기준 https://www.consul.io/downloads 에서 1.11.1 버전 운영체제 맞게 다운

INSUNG CHOI 2 Nov 22, 2022
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more

Eclipse Jetty Canonical Repository This is the canonical repository for the Jetty project, feel free to fork and contribute now! Submitting a patch or

Eclipse Foundation 3.5k Dec 28, 2022
A high-level and lightweight HTTP client framework for Java. it makes sending HTTP requests in Java easier.

A high-level and lightweight HTTP client framework for Java. it makes sending HTTP requests in Java easier.

dromara 1.2k Jan 8, 2023
http-kit is a minimalist, event-driven, high-performance Clojure HTTP server/client library with WebSocket and asynchronous support

HTTP Kit A simple, high-performance event-driven HTTP client+server for Clojure CHANGELOG | API | current Break Version: [http-kit "2.5.3"] ; Publish

HTTP Client/Server for Clojure 2.3k Dec 31, 2022
Standalone Play WS, an async HTTP client with fluent API

Play WS Standalone Play WS is a powerful HTTP Client library, originally developed by the Play team for use with Play Framework. It uses AsyncHttpClie

Play Framework 213 Dec 15, 2022
httpx - CLI to test HTTP/gRPC/RSocket/Kafka... services by HTTP DSL

httpx: CLI for run http file httpx is a CLI to execute requests from JetBrains Http File. Request types supported by httpx HTTP REST PUB/SUB - Apache

servicex-sh 105 Dec 15, 2022