Azure / azure-kusto-java

Microsoft Azure Kusto Library for Java
MIT License
38 stars 43 forks source link

Expected date for the next release #398

Open naracorreia01 opened 1 week ago

naracorreia01 commented 1 week ago

Hello,

Context:

We have two docker container: one is running our service image and one is running the Kusto Emulator image. Our service wants to ingest messages to Kusto Emulator. For that, we created an IngestClient to connect to Kusto Emulator. Since IngestClient is inside a container, we use the hostname of Kusto Emulator container ("kusto-emulator") instead of localhost to make our service container communicate with it. The connection between docker containers uses http://.

Current Problem: since the communication is between two docker containers the hostname is neither localhost nor https://, as referred previously, it fails in the following step as a unsecure connection:

HttpPostUtils.class

private static @NotNull URI parseUriFromUrlString(String url) throws DataClientException {
        try {
            URL cleanUrl = new URL(url);
    --->     if (!"https".equalsIgnoreCase(cleanUrl.getProtocol()) && !url.toLowerCase().startsWith("http://localhost")) {
                throw new DataClientException(url, "Cannot forward security token to a remote service over insecure channel (http://)");
            } else {
                return new URI(cleanUrl.getProtocol(), cleanUrl.getUserInfo(), cleanUrl.getHost(), cleanUrl.getPort(), cleanUrl.getPath(), cleanUrl.getQuery(), cleanUrl.getRef());
            }
        } catch (MalformedURLException | URISyntaxException var2) {
            Exception e = var2;
            throw new DataClientException(url, "Error parsing target URL in post request:" + ((Exception)e).getMessage(), e);
        }
    }

public static String post(CloseableHttpClient httpClient, String urlStr, AbstractHttpEntity requestEntity, long timeoutMs, Map<String, String> headers) throws DataServiceException, DataClientException {
  --->    URI url = parseUriFromUrlString(urlStr);
        [...]
    }
ClientImpl.class

    private KustoOperationResult executeStreamingIngestImpl(String clusterEndpoint, InputStream stream, String blobUrl, ClientRequestProperties properties, boolean leaveOpen) throws DataServiceException, DataClientException {

        [...]
        this.validateEndpoint();
                AbstractHttpEntity entity = isStreamSource ? new InputStreamEntity(new UncloseableStream(stream)) : new StringEntity((new IngestionSourceStorage(blobUrl)).toString(), ContentType.APPLICATION_JSON);
                String response = (String)MonitoredActivity.invoke(() -> {
         --->       return HttpPostUtils.post(this.httpClient, clusterEndpoint, entity, timeoutMs + (long)CLIENT_SERVER_DELTA_IN_MILLISECS, headers);
                }, "ClientImpl.executeStreamingIngest");

    }

Thank you!

AsafMah commented 4 days ago

The behavior still exists in master.

The real issue is that the SDK doesn't properly support an Unauthenticated connection, like for the Emulator. We'll try to see how we can adress that

naracorreia01 commented 3 days ago

Okay, thank you!