Repository navigation
State Examples Don't Include the StateStore Instructions & the Examples Err #909
Description
Expected Behavior
I would expect to be able to follow line by line commands from the README and have a working example.
As of now, there are a few examples that are missing a mongo-statestore or redis-statestore yaml.
- this query state example (mongo-statestore)
- the other state example here (mongo-statestore)
- the tracing example (redis-statestore)
I believe a docker-compose command should be added as a step in the respective READMEs for users to be able to go thru the examples without any issues. Similar to how the Kafka example here has a docker-compose.yml file to create a local kafka instance with the relevant steps mentioned in the README -- the same thing should be added for the examples listed above.
Actual Behavior
For the querystate example in the repo here, it looks to be querying the saved state from a mongo-statestore, but never actually includes any information to a user on how to create the mongo-statestore. As a result, the example is unable to run and errs:
$ dapr run --components-path ./components/state --app-id query-state-example -H 3600 -- java -Ddapr.api.protocol=HTTP -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.querystate.QuerySavedState
Flag --components-path has been deprecated, This flag is deprecated and will be removed in the future releases. Use "resources-path" flag instead
ℹ️ Starting Dapr with id query-state-example. HTTP Port: 3600. gRPC Port: 51986
ℹ️ Checking if Dapr sidecar is listening on HTTP port 3600
INFO[0000] starting Dapr Runtime -- version 1.11.3 -- commit 9f99c6adca78dfc04b8063974f27b3a7534ae798 app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] log level set to: info app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] metrics server started on :51987/ app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.metrics type=log ver=1.11.3
INFO[0000] Resiliency configuration loaded app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] standalone mode configured app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] app id: query-state-example app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] mTLS is disabled. Skipping certificate request and tls validation app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Dapr trace sampler initialized: DaprTraceSampler(P=1.000000) app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] local service entry announced: query-state-example -> 192.168.0.2:51988 app_id=query-state-example component="mdns (nameResolution/v1)" instance=Cassandras-MacBook-Pro.local scope=dapr.contrib type=log ver=1.11.3
INFO[0000] Initialized name resolution to mdns app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading components… app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
WARN[0005] Error processing component, daprd process will exit gracefully app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
FATA[0005] process component mongo-statestore error: [INIT_COMPONENT_FAILURE]: initialization error occurred for mongo-statestore (state.mongodb/v1): init timeout for component mongo-statestore exceeded after 5s app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
❌ The daprd process exited with error code: exit status 1
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C⚠ Dapr sidecar is not listening on HTTP port: dial tcp 127.0.0.1:3600: connect: connection refused
ℹ️ Checking if Dapr sidecar is listening on GRPC port 51986
⚠ Dapr sidecar is not listening on GRPC port: dial tcp 127.0.0.1:51986: connect: connection refused
⚠ Dapr sidecar might not be responding.
== APP == 14:40:25.950 [main] WARN io.dapr.client.DaprClientBuilder - HTTP client protocol is deprecated and will be removed in Dapr's Java SDK version 1.10.
== APP == Waiting for Dapr sidecar ...
== APP == 14:40:26.120 [main] DEBUG reactor.util.Loggers - Using Slf4j logging framework
== APP == Exception in thread "main" java.lang.reflect.InvocationTargetException
== APP == at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
== APP == at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
== APP == at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
== APP == at java.base/java.lang.reflect.Method.invoke(Method.java:566)
== APP == at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
== APP == at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
== APP == at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
== APP == at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
== APP == Caused by: java.lang.reflect.InvocationTargetException
== APP == at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
== APP == at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
== APP == at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
== APP == at java.base/java.lang.reflect.Method.invoke(Method.java:566)
== APP == at io.dapr.examples.DaprMainApplication.main(DaprMainApplication.java:37)
== APP == ... 8 more
== APP == Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused (Connection refused)
== APP == at io.dapr.utils.NetworkUtils.lambda$waitForSocket$0(NetworkUtils.java:53)
== APP == at io.dapr.utils.NetworkUtils.callWithRetry(NetworkUtils.java:89)
== APP == at io.dapr.utils.NetworkUtils.waitForSocket(NetworkUtils.java:44)
== APP == at io.dapr.client.DaprClientHttp.lambda$waitForSidecar$0(DaprClientHttp.java:141)
== APP == at reactor.core.publisher.MonoRunnable.block(MonoRunnable.java:66)
== APP == at io.dapr.examples.querystate.QuerySavedState.main(QuerySavedState.java:53)
== APP == ... 13 more
== APP == Caused by: java.net.ConnectException: Connection refused (Connection refused)
== APP == at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
== APP == at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
== APP == at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
== APP == at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
== APP == at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
== APP == at java.base/java.net.Socket.connect(Socket.java:609)
== APP == at io.dapr.utils.NetworkUtils.lambda$waitForSocket$0(NetworkUtils.java:50)
== APP == ... 18 more
❌ The App process exited with error code: exit status 1
⚠ Could not update sidecar metadata for cliPID: PUT http://127.0.0.1:3600/v1.0/metadata/cliPID giving up after 5 attempt(s): Put "http://127.0.0.1:3600/v1.0/metadata/cliPID": dial tcp 127.0.0.1:3600: connect: connection refused
ℹ️ Updating metadata for appPID: 31046
⚠ Could not update sidecar metadata for appPID: PUT http://127.0.0.1:3600/v1.0/metadata/appPID giving up after 5 attempt(s): Put "http://127.0.0.1:3600/v1.0/metadata/appPID": dial tcp 127.0.0.1:3600: connect: connection refused
ℹ️ Updating metadata for app command: java -Ddapr.api.protocol=HTTP -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.querystate.QuerySavedState
⚠ Could not update sidecar metadata for appCommand: PUT http://127.0.0.1:3600/v1.0/metadata/appCommand giving up after 5 attempt(s): Put "http://127.0.0.1:3600/v1.0/metadata/appCommand": dial tcp 127.0.0.1:3600: connect: connection refused
ℹ️
terminated signal received: shutting down
❌ Error exiting Dapr: exit status 1
❌ Error exiting App: exit status 1
Key err from above is:
FATA[0005] process component mongo-statestore error: [INIT_COMPONENT_FAILURE]: initialization error occurred for mongo-statestore (state.mongodb/v1): init timeout for component mongo-statestore exceeded after 5s app_id=query-state-example instance=Cassandras-MacBook-Pro.local scope=dapr.runtime type=log ver=1.11.3
❌ The daprd process exited with error code: exit status 1
This same thing occurs for the all examples.
Steps to Reproduce the Problem
Follow the README instructions here for the query state example
Follow the README instructions here for the state example
Follow the README instructions here for the tracing example
Solution
copy over the local-test-mongo.yml from the sdk-tests/ to both relevant example directories and do the same for the redis example. Or, copy over the yaml from this directory to the local example directory and use that as the mongo/redis configuration. Reference it like the Kafka example and add the command to the README instructions. Something like: docker-compose -f ../sdk-tests/deploy/local-test-mongo.yml up -d with the relevant cleanup command too: docker-compose -f ../sdk-tests/deploy/local-test-mongo.yml down
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriaged
Activity
ejba commentedon Sep 14, 2023
May I suggest to use testcontainers to launch the containers? It would require less instructions to follow in order to run the examples.
artursouza commentedon Sep 22, 2023
That is an interesting discussion. Maybe have it as a separate issue since there is the side of hiding "too much" from the user.
olitomlinson commentedon Nov 16, 2023
+1 for this issue. It's not a great DevEx when following the readme and it doesn't work.
Just tried to run the basic state example (which doesn't depend on Mongo), but dapr is blowing up because it's expecting a
mongocomponent to be installed.Had to manually remove the mongo component from the components folder.
javier-aliaga commentedon Oct 15, 2026
Fixed, readme works out of the box