Transaction announce gave unexpected end of stream reached error message

hungtrinhduy ()
Hi guys,

I'm trying to make a transaction using api: http://host : port/transaction/announce.

To get a quick overview of how am I doing this, here is some code:

String privateKeySender = "some-private-key"; String publicKeySender = "some-public-key"; ​String recipientAddress = "some-address"; Transaction transaction = new Transaction(System.currentTimeMillis(), publicKeySender, recipientAddress); byte[] data = transaction.getFinalByteArray(); String dataHex = bytesToHex(data); byte[] signature = transaction.sign(data, privateKeySender, publicKeySender).getBytes(); String signatureHex = bytesToHex(signature); System.out.println("data " + dataHex); System.out.println("signature " + signatureHex);
The is provided at:

I followed the guidance given from here

The transaction.sign() function above is taken from nem-core open source

After I've got the data and the signature from above, I prepared a json string as follow:

{ "data": "010100000100006856a21a2b20000000623461313637313637616437376432633234393339666539396138383637373836666535653836336237346332343938663139393061656463356261616133360005ea060000000066b01a2b280000004d414e4f4445475a44365854534d323442524d4f5056574b36494d535648424f4147564e4158424500e876480000000000000000", "signature": "c200b1e0f5833b4255601c6b8cdc0224a36b3b45285402660b69e51621298fd6388a934224bfe1e919144fb90a2b1e79c27caa3f1fd8982755ce198f2248eb08" }
and I used postman to send the request and here is the response I've got back:

{ "timeStamp": 29129527, "error": "Internal Server Error", "message": "unexpected end of stream reached", "status": 500 }There is nothing like this as given from Appendix B: NIS Errors

I also noticed that the System.currentTimeMilis is not what timestamp is aimed to be. According to Nem document:
The number of seconds elapsed since the creation of the nemesis block. Future timestamps are not allowed. Transaction validation detects future timestamps and returns an error in that case. Network time synchronization ensures that any NEM software component will use valid timestamps when creating transactions.First I couldn't find any document how to exactly do this. So I put the current server timestamp plus some seconds. Tried again with postman gave the same response.

Any help would be appreciated!

tomotomo9696 ()
Hello hungtrinhduy ,

In NEM, we use the number of seconds elapsed from 2015/3/29 0:6:25 UTC as a timestamp.

In Java, you get in the following manner.

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone( "UTC" )); cal.set(2015, 3-1, 29, 0, 6, 25); Long NEMTimeStamp = (new Date().getTime()/1000) - (cal.getTimeInMillis()/1000);
I hope this will help you.