Debugging with local Fluence node
Keep your write-test-fix cycle short by debugging your application locally, without waiting for deployment and network.
You will need Docker installed.
NOTE: For this guide, you will need compiled Wasm code. Please read here to learn about compilation to Wasm.
Start your application
Run the following command in terminal, it will start your application in a Docker container:
docker run --rm -v /path/to/your/code.wasm:/code/code.wasm -p 30000:30000 fluencelabs/frun
To connect to your application from JS client use
import * as fluence from "fluence"; ... let appId = 1 fluence.directConnect("localhost", 30000, appId);
appId could be any number. You do not need to specify the correct
appId for local testing.
connect method instead of
directConnect for an application deployed in the Fluence network. Read here to learn how to interact with deployed applications.
[Mon Apr 22 16:03:31 MSK 2019, info, Main$] Tx request. appId: 1 [Mon Apr 22 16:03:31 MSK 2019, info, Main$] Tx: 'Fluence' INFO [hello_world2_2018] Fluence has been successfully greeted
Tx: 'Fluence' is our request,
INFO [hello_world2_2018] Fluence has been successfully greeted is logs from code. How to write logs from code code you can see in backend guides.
After this get response
request.result(). And we will see the result:
[Mon Apr 22 16:03:31 MSK 2019, info, Main$] Query request. appId: 1, path: sessionId/0, data: Some() [Mon Apr 22 16:03:31 MSK 2019, info, TxProcessor] Queried result: Hello, world! From user Fluence
NOTE: You can also send requests from command line with curl, read here for more.