node-moodle-client icon indicating copy to clipboard operation
node-moodle-client copied to clipboard

I'm getting error ECONNRESET when uploading a lot of users

Open Milanw2 opened this issue 8 years ago • 2 comments

I have to upload every user one by one because of the thing that if I upload a JSON with existing users in it, it doesn't upload any user. But now I'm getting these errors for every failed uploaded user:

[Unhandled rejection RequestError: Error: read ECONNRESET
    at new RequestError (C:\Users\Milan\Documents\Octopus\Octopus 2.0\node_modules\request-promise\lib\errors.js:11:15)
    at Request.RP$callback [as _callback] (C:\Users\Milan\Documents\Octopus\Octopus 2.0\node_modules\request-promise\lib\rp.js:60:32)
    at self.callback (C:\Users\Milan\Documents\Octopus\Octopus 2.0\node_modules\request\request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:191:7)
    at Request.onRequestError (C:\Users\Milan\Documents\Octopus\Octopus 2.0\node_modules\request\request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:191:7)
    at Socket.socketErrorListener (_http_client.js:358:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at emitErrorNT (net.js:1279:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)](url)

Milanw2 avatar May 12 '17 10:05 Milanw2

It is not clear to me how is this directly related to the moodle client. May it be rather caused by the way how you use it in your app?

mudrd8mz avatar May 12 '17 10:05 mudrd8mz

Then please tell me what I'm doing wrong. This is my code:

function send_user_to_moodle(client, username, password, firstname, lastname, email) {
    client.call({
        wsfunction: "core_user_create_users",
        method: "POST",
        args: {
            users: [
                {
                    username: username,
                    password: password,
                    firstname: firstname,
                    lastname: lastname,
                    email: email
                }
            ]
        }
    }).then(function (info) {
        }
    });
};

This code is run over and over again for 50.000 users. This because of the reason explained in the original question.

Thanks for your quick reply!

Milanw2 avatar May 12 '17 11:05 Milanw2