betanet examples - blockUntilComplete() hangs indefinitely
Both messaging and tokens examples show the desired results, but after blockUntilCompete() is called, the programs run indefinitely. I end up shutting them down. That's either using Bootstrap.LOCALHOST_SINGLENODE or Bootstrap.LOCALHOST_HOST.
I dug into the method, and it is an observer of the transaction being finalized on the DLT. So that doesn't seem to happen.
Thanks for your feedback @jim-obrien-orig!
A bit of a confusion on my end: what happens after that hour of hanging (the title and the description seems to suggest different things)?
I just kill the process. I updated the subject/description. Thanks for your help.
Thanks for the quick update.
This doesn't seem like the right behaviour. We'll have a closer look at exactly what's going on here. Stay tuned...
I have this issue too in Linux, it seems to work on Windows.
@methk I was using mac os x
@methk @jim-obrien-orig Thank you for your continued engagement on this topic. I have had a look at this from a couple of different angles but I seem to have a problem reproducing the issue (I'm on mac too). I start to think this might be an environment issue.
Could you please give example of a bare minimum example code that triggers this for you? What does your build.gradle file look like? And how do you initialise your app and the RadixApplicationAPI instance ("bare minimum code snippet")?
Ok - here's too examples - either compiled against
implementation 'com.radixdlt:radixdlt-java:dbfd5064e5'
or compiled against release/1.0.0-beta.2
Both get subscribed messages, but hang indefinitely on blockUntilComplete()
This is the messages example that hangs:
package com.jimob.radix.examples;
import com.radixdlt.client.application.RadixApplicationAPI;
import com.radixdlt.client.application.RadixApplicationAPI.Result;
import com.radixdlt.client.application.identity.RadixIdentities;
import com.radixdlt.client.application.identity.RadixIdentity;
import com.radixdlt.client.atommodel.accounts.RadixAddress;
import com.radixdlt.client.core.Bootstrap;
import org.radix.utils.RadixConstants;
public class MessagesExample {
public static void main(String[] args) {
// Create a new public key identity
final RadixIdentity radixIdentity = RadixIdentities.createNew();
// Initialize api layer
RadixApplicationAPI api = RadixApplicationAPI.create(Bootstrap.LOCALHOST_SINGLENODE, radixIdentity);
// Sync with network
api.pull();
System.out.println("My address: " + api.getAddress());
System.out.println("My public key: " + api.getPublicKey());
// Print out all past and future messages
api.observeMessages().subscribe(System.out::println);
// Send a message to an address
RadixAddress toAddress = RadixAddress.from("JEbhKQzBn4qJzWJFBbaPioA2GTeaQhuUjYWkanTE6N8VvvPpvM8");
Result result = api.sendMessage(toAddress, "Hello".getBytes(RadixConstants.STANDARD_CHARSET), true);
result.blockUntilComplete();
}
}
Output:
My address: JFDCw4FARBGKzwYQbmbCn44PpUJE1JcNsH4yXd4S8fbhSDp4qD9
My public key: AovPVgC6L2toVt+CoZ6fSriyutUWj5w2upD+ruu5NHWP
1574891472922 JFDCw4FARBGKzwYQbmbCn44PpUJE1JcNsH4yXd4S8fbhSDp4qD9 -> JEbhKQzBn4qJzWJFBbaPioA2GTeaQhuUjYWkanTE6N8VvvPpvM8: DECRYPTED SGVsbG8=
Tokens example:
package com.jimob.radix.examples;
import com.radixdlt.client.application.RadixApplicationAPI;
import com.radixdlt.client.application.RadixApplicationAPI.Result;
import com.radixdlt.client.application.RadixApplicationAPI.Transaction;
import com.radixdlt.client.application.identity.RadixIdentities;
import com.radixdlt.client.application.identity.RadixIdentity;
import com.radixdlt.client.application.translate.tokens.CreateTokenAction;
import com.radixdlt.client.application.translate.tokens.CreateTokenAction.TokenSupplyType;
import com.radixdlt.client.application.translate.tokens.MintTokensAction;
import com.radixdlt.client.application.translate.tokens.TokenUnitConversions;
import com.radixdlt.client.atommodel.accounts.RadixAddress;
import com.radixdlt.client.core.Bootstrap;
import com.radixdlt.client.core.atoms.particles.RRI;
import java.math.BigDecimal;
public class TokensExample {
public static void main(String[] args) {
// Create a new public key identity
final RadixIdentity radixIdentity = RadixIdentities.createNew();
// Initialize api layer
RadixApplicationAPI api = RadixApplicationAPI.create(Bootstrap.LOCALHOST_SINGLENODE, radixIdentity);
// Constantly sync account with network
api.pull();
System.out.println("My address: " + api.getAddress());
System.out.println("My public key: " + api.getPublicKey());
// Create a unique identifier for the token
RRI tokenRRI = RRI.of(api.getAddress(), "JOSH");
// Observe all past and future transactions
api.observeTokenTransfers()
.subscribe(System.out::println);
// Observe current and future total balance
api.observeBalance(tokenRRI)
.subscribe(balance -> System.out.println("My Balance: " + balance));
// Create token and mint
Transaction transaction = api.createTransaction();
transaction.stage(CreateTokenAction.create(
tokenRRI,
"Joshy Token",
"The Best Coin Ever",
BigDecimal.ZERO,
TokenUnitConversions.getMinimumGranularity(),
TokenSupplyType.MUTABLE
));
transaction.stage(MintTokensAction.create(tokenRRI, api.getAddress(), BigDecimal.valueOf(1000000.0)));
Result createTokenAndMint = transaction.commitAndPush();
createTokenAndMint.toObservable().blockingSubscribe(System.out::println);
// Get token definition
System.out.println(api.getTokenDef(tokenRRI));
// Mint tokens
Result mint = api.mintTokens(tokenRRI, BigDecimal.valueOf(10000.0));
mint.toObservable().blockingSubscribe(System.out::println);
// Burn tokens
Result burn = api.burnTokens(tokenRRI, BigDecimal.valueOf(10000.0));
burn.toObservable().blockingSubscribe(System.out::println);
// Send tokens
RadixAddress toAddress = RadixAddress.from("JEbhKQzBn4qJzWJFBbaPioA2GTeaQhuUjYWkanTE6N8VvvPpvM8");
api.sendTokens(tokenRRI, toAddress, BigDecimal.valueOf(10000.0), "Test Message").toObservable()
.subscribe(System.out::println, Throwable::printStackTrace);
}
}
Output:
My address: JFeHaMcyfn8j3n5mjX6xDN9EQfhbTKp6aSpbZ9Ws2ZcQH7tLqQx
My public key: AsTB2i2HQubg3SlA2BzHUjQ9R9Z0t2BwTLcQy/Hk7BoJ
My Balance: 0
SUBMIT_ATOM_REQUEST 71fecbbf-2bdc-4e8a-9780-10b58a574d42 dcc6e6d7bcc962a1ac2838530d306f10a9c325eb52258ebbb8fa36b135acdee2
SUBMIT_ATOM_SEND 71fecbbf-2bdc-4e8a-9780-10b58a574d42 dcc6e6d7bcc962a1ac2838530d306f10a9c325eb52258ebbb8fa36b135acdee2 localhost:8080
SUBMIT_ATOM_RECEIVED 71fecbbf-2bdc-4e8a-9780-10b58a574d42 dcc6e6d7bcc962a1ac2838530d306f10a9c325eb52258ebbb8fa36b135acdee2 localhost:8080
1574891645530 null -> JFeHaMcyfn8j3n5mjX6xDN9EQfhbTKp6aSpbZ9Ws2ZcQH7tLqQx 1000000.000000000000000000
My Balance: 1000000.000000000000000000
SUBMIT_ATOM_STATUS 71fecbbf-2bdc-4e8a-9780-10b58a574d42 dcc6e6d7bcc962a1ac2838530d306f10a9c325eb52258ebbb8fa36b135acdee2 localhost:8080 STORED {}
Token(JOSH) name(Joshy Token) description(The Best Coin Ever) totalSupply(1000000.000000000000000000) granularity(1E-18) maxSupply(1000000.000000000000000000)
My Balance: 1000000.000000000000000000
SUBMIT_ATOM_REQUEST b7c471ba-d2af-43f2-8732-de55f2e8e76a ace74bbe253ad01ae7cecce1e60f5a394044592b95f9a441b8fa36b135acdee2
SUBMIT_ATOM_SEND b7c471ba-d2af-43f2-8732-de55f2e8e76a ace74bbe253ad01ae7cecce1e60f5a394044592b95f9a441b8fa36b135acdee2 localhost:8080
SUBMIT_ATOM_RECEIVED b7c471ba-d2af-43f2-8732-de55f2e8e76a ace74bbe253ad01ae7cecce1e60f5a394044592b95f9a441b8fa36b135acdee2 localhost:8080
1574891646104 null -> JFeHaMcyfn8j3n5mjX6xDN9EQfhbTKp6aSpbZ9Ws2ZcQH7tLqQx 10000.000000000000000000
My Balance: 1010000.000000000000000000
SUBMIT_ATOM_STATUS b7c471ba-d2af-43f2-8732-de55f2e8e76a ace74bbe253ad01ae7cecce1e60f5a394044592b95f9a441b8fa36b135acdee2 localhost:8080 STORED {}
My Balance: 1010000.000000000000000000
SUBMIT_ATOM_REQUEST 7e386bee-2bf5-4bfe-a816-4ff511b05967 9774f7393bf019996ea8bd5e276a7b41f4a9e440eaa72d16b8fa36b135acdee2
SUBMIT_ATOM_SEND 7e386bee-2bf5-4bfe-a816-4ff511b05967 9774f7393bf019996ea8bd5e276a7b41f4a9e440eaa72d16b8fa36b135acdee2 localhost:8080
SUBMIT_ATOM_RECEIVED 7e386bee-2bf5-4bfe-a816-4ff511b05967 9774f7393bf019996ea8bd5e276a7b41f4a9e440eaa72d16b8fa36b135acdee2 localhost:8080
1574891646343 JFeHaMcyfn8j3n5mjX6xDN9EQfhbTKp6aSpbZ9Ws2ZcQH7tLqQx -> null 10000.000000000000000000
My Balance: 1000000.000000000000000000
SUBMIT_ATOM_STATUS 7e386bee-2bf5-4bfe-a816-4ff511b05967 9774f7393bf019996ea8bd5e276a7b41f4a9e440eaa72d16b8fa36b135acdee2 localhost:8080 STORED {}
My Balance: 1000000.000000000000000000
SUBMIT_ATOM_REQUEST 72f635c5-ff3a-42f2-a391-6bcc66c01120 ec633a9c5ccc440bfe02e4e86cf1dc1591634e58114366747be4ca91f62f1179
SUBMIT_ATOM_SEND 72f635c5-ff3a-42f2-a391-6bcc66c01120 ec633a9c5ccc440bfe02e4e86cf1dc1591634e58114366747be4ca91f62f1179 localhost:8080
SUBMIT_ATOM_RECEIVED 72f635c5-ff3a-42f2-a391-6bcc66c01120 ec633a9c5ccc440bfe02e4e86cf1dc1591634e58114366747be4ca91f62f1179 localhost:8080
1574891646540 JFeHaMcyfn8j3n5mjX6xDN9EQfhbTKp6aSpbZ9Ws2ZcQH7tLqQx -> JEbhKQzBn4qJzWJFBbaPioA2GTeaQhuUjYWkanTE6N8VvvPpvM8 10000.000000000000000000 [B@18ed52a7
My Balance: 990000.000000000000000000
SUBMIT_ATOM_STATUS 72f635c5-ff3a-42f2-a391-6bcc66c01120 ec633a9c5ccc440bfe02e4e86cf1dc1591634e58114366747be4ca91f62f1179 localhost:8080 STORED {}
My Balance: 990000.000000000000000000
Hi,
Facing exactly the same issue described above but on Windows 10 Pro using Java/JavaC 11.0.9 and com.radixdlt:radixdlt-java:dbfd5064e5.
Additionally, I had to add a line of code to address an issue related to "No password supplied for PKCS#12". Not sure if the rest are facing the same. But adding "System.setProperty("javax.net.ssl.trustStoreType", "JKS");" seems to do the trick.
The getting started example (https://docs.radixdlt.com/radixdlt-java/guides/getting-started), however, runs smoothly.