Error parsing host address when executing queries
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
- Clone this repo: https://github.com/mmajis/ksqldb-query-bug-repro
- Put your confluent cloud api key and secret in a
.envfile 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>
docker-compose up -ddocker-compose exec ksqldb-cli bashLOG_DIR=. ksqldb http://ksql-server:8088- Create a stream:
CREATE STREAM my_stream (my_value VARCHAR) WITH (
VALUE_FORMAT = 'JSON',
KAFKA_TOPIC = 'my_stream_topic',
PARTITIONS=1,
REPLICAS=3);
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.
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.
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.
I sorted it by removing trailing slash from KSQL_LISTENERS. I was passing in KSQL_LISTENERS=http://0.0.0.0:8088/
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
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.
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.
Looks like the fix didn't totally fix the issue - it fixed a similar issue