I made some test codes to send transactions with Node.js client library, and received the below error response. I cannot find the cause of this error. Did this happen to anyone before? And can anyone explain what went wrong here?

Error: Request Error: Request too long
    at Object.requestError (/var/iota-node/node_modules/iota.lib.js/lib/errors/requestErrors.js:11:12)
    at makeRequest.prepareResult (/var/iota-node/node_modules/iota.lib.js/lib/utils/makeRequest.js:293:24)
    at exports.XMLHttpRequest.request.onreadystatechange (/var/iota-node/node_modules/iota.lib.js/lib/utils/makeRequest.js:71:25)
    at exports.XMLHttpRequest.dispatchEvent (/var/iota-node/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/var/iota-node/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (/var/iota-node/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)

Codes I used to make transactions

    const IOTA = require('iota.lib.js');
    const fs=require("fs");

    const iota = new IOTA({ provider: 'http://iota.node.com:14265' })

    var content = fs.readFileSync("site.pdf", "base64");
    const trytes = 'MYADDRESS';
    var messageToSend = {
        'name': 'Test',
        'message': 'test message',
        'file_content': content

    var messageStringified = JSON.stringify(messageToSend);
    var message = iota.utils.toTrytes(messageStringified);
    var tag = iota.utils.toTrytes('testtag');

    const transfers = [
            value: 0,
            address: trytes,
            message: message,
            tag: tag

    iota.api.sendTransfer(trytes, 3, 14, transfers, (error, success) => {
        if (error) {
        } else {
  • 1
    Can you show the code where you built the request? I assume that some field (for example the tag) is too long and it is not correctly handled in the library, therefore iri will complain about this when it receives the trytes. – mihi May 4 '18 at 18:24
  • @mihi I added my codes, can you see if you can find any mistakes I might made? thanks – Michael Li May 8 '18 at 15:31
  • How big is the file? Or in other words, how many transactions did prepareTransfers make from it? ``` iota.api.prepareTransfers(trytes, transfers, (error, success) => { if (error) { console.log("Unable to prepare") } else { console.log("Prepared" + success.length+" transactions"); } }); ``` I tested your code with a fairly small file (16K) against iota.lib.js 0.4.7 and it worked (thetangle.org/bundle/…) – mihi May 8 '18 at 20:06
  • Also make sure that your address is valid (81 characters of A-Z and 9 only) – mihi May 8 '18 at 20:07

It seems to be a client error, because of a large request size. Besides, publishing large files as transactions requires a large amount of Proof-of-Work, which may take time or cause the connection to close depending on remote node settings. It might be a good idea to split file contents into multiple chunks and attach to tangle in a more granular manner.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.