diff --git a/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherFile.java b/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherFile.java index 71e4e3e57..390062432 100644 --- a/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherFile.java +++ b/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherFile.java @@ -21,7 +21,7 @@ public class AmopPublisherFile { .getPath(); /** - * @param args topicName, isBroadcast: true/false, fileName, count + * @param args topicName, isBroadcast: true/false, fileName, count, timeout * @throws Exception */ public static void main(String[] args) throws Exception { @@ -35,7 +35,10 @@ public static void main(String[] args) throws Exception { Integer count = Integer.parseInt(args[3]); BcosSDK sdk = BcosSDK.build(publisherFile); Amop amop = sdk.getAmop(); - + Integer timeout = 6000; + if (args.length > 4) { + timeout = Integer.parseInt(args[4]); + } System.out.println("3s ..."); Thread.sleep(1000); System.out.println("2s ..."); @@ -59,23 +62,27 @@ public static void main(String[] args) throws Exception { AmopMsgOut out = new AmopMsgOut(); out.setType(TopicType.NORMAL_TOPIC); out.setContent(content); - out.setTimeout(6000); + out.setTimeout(timeout); out.setTopic(topicName); ResponseCallback cb = new ResponseCallback() { @Override public void onResponse(Response response) { - - System.out.println( - "Step 3:Get response, { errorCode:" - + response.getErrorCode() - + " error:" - + response.getErrorMessage() - + " seq:" - + response.getMessageID() - + " content:" - + new String(response.getContentBytes()) - + " }"); + if (response.getErrorCode() == 102) { + System.out.println( + "Step 3: Timeout, maybe your file is too large or your gave a short timeout. Add a timeout arg, topicName, isBroadcast: true/false, fileName, count, timeout"); + } else { + System.out.println( + "Step 3:Get response, { errorCode:" + + response.getErrorCode() + + " error:" + + response.getErrorMessage() + + " seq:" + + response.getMessageID() + + " content:" + + new String(response.getContentBytes()) + + " }"); + } } }; if (isBroadcast) { diff --git a/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherPrivateFile.java b/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherPrivateFile.java index 4432f4d5f..34d2b736f 100644 --- a/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherPrivateFile.java +++ b/src/demo/java/org/fisco/bcos/sdk/demo/amop/tool/AmopPublisherPrivateFile.java @@ -25,8 +25,8 @@ public class AmopPublisherPrivateFile { .getPath(); /** - * @param args topicName, pubKey1, pubKey2, isBroadcast: true/false, fileName, count. if only - * one public key please fill pubKey2 with null + * @param args topicName, pubKey1, pubKey2, isBroadcast: true/false, fileName, count, timeout. + * if only one public key please fill pubKey2 with null * @throws Exception */ public static void main(String[] args) throws Exception { @@ -40,6 +40,10 @@ public static void main(String[] args) throws Exception { Boolean isBroadcast = Boolean.valueOf(args[3]); String fileName = args[4]; Integer count = Integer.parseInt(args[5]); + Integer timeout = 6000; + if (args.length > 6) { + timeout = Integer.parseInt(args[6]); + } BcosSDK sdk = BcosSDK.build(publisherFile); Amop amop = sdk.getAmop(); // todo setup topic @@ -83,23 +87,27 @@ public static void main(String[] args) throws Exception { AmopMsgOut out = new AmopMsgOut(); out.setType(TopicType.PRIVATE_TOPIC); out.setContent(content); - out.setTimeout(6000); + out.setTimeout(timeout); out.setTopic(topicName); ResponseCallback cb = new ResponseCallback() { @Override public void onResponse(Response response) { - - System.out.println( - "Step 3:Get response, { errorCode:" - + response.getErrorCode() - + " error:" - + response.getErrorMessage() - + " seq:" - + response.getMessageID() - + " content:" - + new String(response.getContentBytes()) - + " }"); + if (response.getErrorCode() == 102) { + System.out.println( + "Step 3: Timeout, maybe your file is too large or your gave a short timeout. Add a timeout arg, topicName, isBroadcast: true/false, fileName, count, timeout"); + } else { + System.out.println( + "Step 3:Get response, { errorCode:" + + response.getErrorCode() + + " error:" + + response.getErrorMessage() + + " seq:" + + response.getMessageID() + + " content:" + + new String(response.getContentBytes()) + + " }"); + } } }; if (isBroadcast) {