ksql icon indicating copy to clipboard operation
ksql copied to clipboard

Error parsing host address when executing queries

Open mmajis opened this issue 6 years ago • 7 comments

Describe the bug

Running a push query in ksqldb v0.7.1 errors out with Error parsing host address http://<docker network host address>:8088/. Expected format host:port.

Having had a quick look at the code, it looks like StreamsConfig.APPLICATION_SERVER_CONFIG has wrong format when executing the query.

To Reproduce

  1. Clone this repo: https://github.com/mmajis/ksqldb-query-bug-repro
  2. Put your confluent cloud api key and secret in a .env file inside the repo to configure Confluent Cloud connection:
CC_API_KEY=<your api key>
CC_API_SECRET=<your api secret>
CC_ADDRESS=<your confluent cloud bootstrap server address and port>
  1. docker-compose up -d
  2. docker-compose exec ksqldb-cli bash
  3. LOG_DIR=. ksqldb http://ksql-server:8088
  4. Create a stream:
  CREATE STREAM my_stream (my_value VARCHAR) WITH (
  VALUE_FORMAT = 'JSON',
  KAFKA_TOPIC = 'my_stream_topic', 
  PARTITIONS=1, 
  REPLICAS=3);
  1. SELECT * FROM my_stream EMIT CHANGES;

Expected behavior

Expected the query SELECT * FROM my_stream EMIT CHANGES; to start running.

Actual behaviour

The ksqlDB-cli outputs this error: Error parsing host address http://<docker-compose_ksql-server_hostname>:8088/. Expected format host:port.

Stack trace in ksqldb-cli log:

[2020-02-27 18:53:05,739] ERROR Error parsing host address http://1130da4e15fb:8088/. Expected format host:port.
org.apache.kafka.streams.KafkaStreams.parseHostInfo(KafkaStreams.java:818)
org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:707)
org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:584)
io.confluent.ksql.query.KafkaStreamsBuilderImpl.buildKafkaStreams(KafkaStreamsBuilderImpl.java:43)
io.confluent.ksql.query.QueryExecutor.buildTransientQuery(QueryExecutor.java:165)
io.confluent.ksql.engine.EngineExecutor.executeQuery(EngineExecutor.java:129)
io.confluent.ksql.engine.KsqlEngine.executeQuery(KsqlEngine.java:215)
io.confluent.ksql.rest.server.resources.streaming.StreamedQueryResource.handlePushQuery(StreamedQueryResource.java:269)
io.confluent.ksql.rest.server.resources.streaming.StreamedQueryResource.handleStatement(StreamedQueryResource.java:208)
io.confluent.ksql.rest.server.resources.streaming.StreamedQueryResource.streamQuery(StreamedQueryResource.java:161)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
...omitted tens of glassfish and jetty lines...

Additional context

This used to work with v0.6.0.

There's a separate branch local_kafka in the demo repo where the querying works. So the issue seems to be related to the configuration necessary to use Confluent Cloud.

mmajis avatar Feb 28 '20 13:02 mmajis

I also ran into the same issue, but while using ksqlDB 0.7

~~I'm not sure if it's relevant, but I've only seen it when creating streams that are JSON formatted like the example above. Have not encountered it when using a purely AVRO pipeline.~~

Use of Confluent Cloud seems to be the common thread.

terryf82 avatar Mar 05 '20 04:03 terryf82

Hi - Is there any work arounds? I don't use the cloud at all. I just spin a container of cp-ksql-server:5.4.1 and then connect with confluentinc/cp-ksql-cli

I can create streams but if I ever try SELECT * FROM my_stream EMIT CHANGES; it gives error as above with the ksql container ID as the host.

yfaykya avatar Mar 10 '20 16:03 yfaykya

I sorted it by removing trailing slash from KSQL_LISTENERS. I was passing in KSQL_LISTENERS=http://0.0.0.0:8088/

yfaykya avatar Mar 11 '20 13:03 yfaykya

Yes, it works without the trailing slash there.

Notably this page has some trailing slashes for KSQL_LISTENERS in the examples: https://github.com/confluentinc/ksql/blob/master/docs-md/operate-and-deploy/installation/install-ksqldb-with-docker.md

mmajis avatar Mar 11 '20 14:03 mmajis

Confirming that removing the trailing slash also worked here.

@rodesai this was the issue I mentioned via Slack last week. Seems like a documentation bug rather than a technical one.

terryf82 avatar Mar 16 '20 02:03 terryf82

Since the value for KSQL_LISTENERS looks like a URI I think it'd be good for developer experience that the parsing could handle a trailing slash.

mmajis avatar Mar 16 '20 14:03 mmajis

Looks like the fix didn't totally fix the issue - it fixed a similar issue

agavra avatar Apr 15 '20 22:04 agavra