I'm using the JOTA : Library 0.9.11-SNAPSHOT API.
I am using Eclipse JUnit testing for the example found at https://github.com/iotaledger/iota.lib.java/blob/master/jota/src/test/java/jota/SendMessageTest.java - slightly modified code pasted below.
I am having sporadic success getting transactions processed on servers. I modified SendMessage, as shown, to allow me to define the PROTOCOL, HOST, and PORT properties when creating the iotaClient. This is done so that I can easily test servers. I turn a set of properties on by uncommenting the line. I added a comment at end of each property line with the results of each test. I got the servers from several listings:
https://iotanode.host/
https://www.tangle-nodes.com/?sorts[load]=1&sorts[tls]=-1
http://www.iotatoken.nl/
Can someone please explain why I am getting sporadic results? Many severs simply do not work, others that do work are not consistent - sometimes they work, sometimes they fail for runs just minutes a part.
Thanks, Bob
package jota;
import jota.dto.response.SendTransferResponse;
import jota.error.ArgumentException;
import jota.model.Transfer;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.core.IsNull;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import cfb.pearldiver.PearlDiverLocalPoW;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertThat;
public class SendMessageTestOrig {
private static final String TEST_SEED1 = "IHDEENZYITYVYSPKAURUZAQKGVJEREFDJMYTANNXXGPZ9GJWTEOJJ9IPMXOGZNQLSNMFDSQOTZAEETUEA";
private static final String TEST_ADDRESS_WITH_CHECKSUM_SECURITY_LEVEL_2 = "LXQHWNY9CQOHPNMKFJFIJHGEPAENAOVFRDIBF99PPHDTWJDCGHLYETXT9NPUVSNKT9XDTDYNJKJCPQMZCCOZVXMTXC";
private static final String TEST_MESSAGE = "JUSTANOTHERJOTATEST";
private static final String TEST_TAG = "JOTASPAM9999999999999999999";
private static final int MIN_WEIGHT_MAGNITUDE = 14;
private static final int DEPTH = 9;
private IotaAPI iotaClient;
@Before
public void createApiClientInstance() {
//this version uses env vars
// iotaClient = new IotaAPI.Builder()
// .localPoW(new PearlDiverLocalPoW())
// .build();
//trying various servers
iotaClient = new IotaAPI.Builder()
.localPoW(new PearlDiverLocalPoW())
// .protocol("http").host("node01.iotatoken.nl").port("14265") //java.lang.IllegalAccessError: 500
// .protocol("https").host("node02.iotatoken.nl").port("443") //status 500
// .protocol("http").host("node03.iotatoken.nl").port("15265") //usually works for messages, but been getting SocketTimeoutException; sometimes busy see http://www.iotatoken.nl for load
// .protocol("https").host("node04.iotatoken.nl").port("443") //status 500
// .protocol("http").host("node05.iotatoken.nl").port("16265") //java.lang.IllegalAccessError: 500
// .protocol("https").host("node06.iotatoken.nl").port("443") //status 500
// .protocol("https").host("node07.iotatoken.nl").port("17265") //java.net.ConnectException: Failed to connect to node07.iotatoken.nl/80.61.194.94:17265
// .protocol("https").host("node08.iotatoken.nl").port("18265") //javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
// .protocol("http").host("eugeneoldisoft.iotasupport.com").port("14265") //COMMAND not allowed - probably means it doesn't allow messages
// .protocol("http").host("cryptoiota.win").port("14265") //java.lang.IllegalAccessError: 500 While fdatasync: mainnetdb/192995.sst - probably means it doesn't allow messages
// .protocol("http").host("iotanode.farm").port("14265") //Failed to connect
// .protocol("https").host("node.tangle.works").port("443") //java.net.ConnectException: Failed to connect to node.tangle.works/45.76.123.166:443
// .protocol("http").host("5.9.149.169").port("14265") //java.lang.IllegalStateException: Failed to connect to /5.9.149.169:14265
// .protocol("http").host("5.9.137.199").port("14265") //java.net.ConnectException: Failed to connect to /5.9.137.199:14265
// .protocol("http").host("5.9.118.112").port("14265") //java.net.ConnectException: Failed to connect to /5.9.118.112:14265
// .protocol("http").host("88.198.230.98").port("14265") //java.net.ConnectException: Failed to connect to /88.198.230.98:14265
// .protocol("http").host("176.9.3.149").port("14265") //java.net.ConnectException: Failed to connect to /176.9.3.149:14265
// .protocol("http").host("tangle.hom3works.fr").port("14265") //worked, took 30 secs for this short msg, but fails for 677 byte msgs - failed java.io.IOException: unexpected end of stream on Connection{tangle.hom3works.fr:14265, proxy=DIRECT hostAddress=tangle.hom3works.fr/82.64.40.233:14265 cipherSuite=none protocol=http/1.1}
.protocol("http").host("radiantqs.de").port("14265") //worked once, took 2 minutes; other tests never returned
// .protocol("https").host("n1.iotajournal.io").port("443") //npe
// .protocol("https").host("whitey.whitey13.org").port("443") //npe
// .protocol("https").host("iota.xardas.org").port("443") //Connection refused
// .protocol("http").host("superiota-5.ga").port("14265") //Failed to connect
// .protocol("http").host("iota.neterra.net").port("14265") //This operations cannot be executed: The subtangle has not been updated yet.
// .protocol("https").host("iota-nod3.de").port("443") //npe
.build();
}
// @Ignore
@Test
public void shouldSendMessage() throws ArgumentException {
List transfers = new ArrayList();
// for each 2187 trytes in a message one transfer is necessary
transfers.add(new Transfer(TEST_ADDRESS_WITH_CHECKSUM_SECURITY_LEVEL_2, 0, StringUtils.rightPad(TEST_MESSAGE, 2188, '9'), TEST_TAG));
System.out.println("sending...");
SendTransferResponse str = iotaClient.sendTransfer(TEST_SEED1, 2, DEPTH, MIN_WEIGHT_MAGNITUDE, transfers, null, null, false, false);
System.out.println("str.getTransactions: " +str.getTransactions());
System.out.println("str.getSuccessfully: " +Arrays.toString(str.getSuccessfully()));
assertEquals(str.getTransactions().size(), 2);
assertThat(str.getTransactions(), IsNull.notNullValue());
assertThat(str.getSuccessfully(), IsNull.notNullValue());
}
}