Skip to content

Java SDK not using ziti socket with Apache HttpClient5 version 5.4 #679

@ahazeltonNF

Description

@ahazeltonNF

Using HttpClient5 version 5.3.1 works correctly. After upgrading to 5.4.2, socket connection refused errors are observed. Below is a sample that uses the ZitiHttpClientConfiguration that is part of the org.openziti:ziti-springboot-client package but created manually instead of via Spring:

      // This is using the spring boot ZitiHttpClientConfiguration manually.  Normally these would be created as spring beans
      ZitiHttpClientConfiguration zitiHttpClientConfiguration = new ZitiHttpClientConfiguration();
      ZitiConnectionSocketFactory socketFactory = zitiHttpClientConfiguration.connectionSocketFactory(zitiContext);
      ZitiSSLConnectionSocketFactory sslSocketFactory = zitiHttpClientConfiguration.sslConnectionSocketFactory(zitiContext);
      PoolingHttpClientConnectionManager poolingMgr = zitiHttpClientConfiguration.poolingConnectionManager(socketFactory, sslSocketFactory,
          ZitiHttpClientConfiguration.dnsResolver(), null, null);
      CloseableHttpClient client = zitiHttpClientConfiguration.httpClient(poolingMgr, zitiHttpClientConfiguration.connectionKeepAliveStrategy(null), null,
          null);

      HttpGet httpGet = new HttpGet(new URI(myUriString));
      client.execute(httpGet, response -> {
        log.info("Reading response");
        if (response.getCode() == 200) {
          log.info("--- {}", EntityUtils.toString(response.getEntity()));
        } else {
          log.error("Response code {} received", response.getCode());
        }
        return response;
      });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions