Is it possible to run multiple client instances
loykean opened this issue · comments
I'm new to node.js, i like to run multiple bots in the same time with below code but it not work. Could you please confirm the correct coding guideline?
// --- Numbers of active accounts ---
var accounts = [
//{Username: "bot0", Password: "p0", CharSlotIndex: 0},
{Username: "bot1", Password: "p1", CharSlotIndex: 0}
];
// --- Create Instances from configuration ---
var players = [];
accounts.forEach(function (acc) {
var p = new Client({
/* required / Username: acc.Username,
/ required / Password: acc.Password,
/ required / Ip: serverAddress,
/ optional / ServerId: serverId,
/ optional */ CharSlotIndex: acc.CharSlotIndex,
});
players.push(p);
setTimeout(() => {
p.enter();
}, 1000);
});
Hi. Yes - this should be possible - it just that one Client
instance should handle one account. here is an example:
process.env.L2JSC_LOG_LEVEL = "8"; // Debug mode logging
const configuration = {
Ip: "127.0.0.1",
ServerId: 1
};
const accounts = [
{Username: "bot0", Password: "p0", CharSlotIndex: 0},
{Username: "bot1", Password: "p1", CharSlotIndex: 0}
];
const clients = []; // keep reference to each bot client
accounts.forEach(acc => {
const cfg = Object.assign(configuration, acc);
const l2 = new Client();
clients.push(l2);
setTimeout(() => {
l2.enter(cfg);
}, 1000);
});
Thank you for your suggestion, i'll try.
From your snippet seems cannot login sucessfully.
[5/4/2021, 8:15:57 PM] DEBUG MMOConnection Connecting [ '127.0.0.1:2106' ]
[5/4/2021, 8:15:57 PM] DEBUG MMOConnection Connecting [ '127.0.0.1:2106' ]
[5/4/2021, 8:15:57 PM] INFO MMOConnection Connected [ '127.0.0.1:2106' ]
[5/4/2021, 8:15:57 PM] INFO MMOConnection Connected [ '127.0.0.1:2106' ]
[5/4/2021, 8:15:57 PM] DEBUG Init ProtocolRevision [ 50721 ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Receive [ 'Init' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Sending [ 'AuthGameGuard' ]
[5/4/2021, 8:15:57 PM] DEBUG Init ProtocolRevision [ 50721 ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Receive [ 'Init' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Sending [ 'AuthGameGuard' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Receive [ 'GGAuth' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Sending [ 'RequestAuthLogin' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Receive [ 'GGAuth' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Sending [ 'RequestAuthLogin' ]
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Receive [ 'LoginFail' ]
(node:5360) UnhandledPromiseRejectionWarning: REASON_ACCOUNT_IN_USE
(Use node --trace-warnings ...
to show where the warning was created)
(node:5360) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise
which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5360) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero
exit code.
[5/4/2021, 8:15:57 PM] DEBUG LoginClient Receive [ 'LoginFail' ]
(node:5360) UnhandledPromiseRejectionWarning: REASON_ACCOUNT_IN_USE
(node:5360) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise
which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
I've added more delay for 2 seconds seems first account can login but second is failed.
[5/4/2021, 8:09:54 PM] DEBUG MMOConnection Connecting [ '127.0.0.1:2106' ]
[5/4/2021, 8:09:54 PM] INFO MMOConnection Connected [ '127.0.0.1:2106' ]
[5/4/2021, 8:09:54 PM] DEBUG Init ProtocolRevision [ 50721 ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Receive [ 'Init' ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Sending [ 'AuthGameGuard' ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Receive [ 'GGAuth' ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Sending [ 'RequestAuthLogin' ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Receive [ 'ServerList' ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Sending [ 'RequestServerLogin' ]
[5/4/2021, 8:09:54 PM] DEBUG LoginClient Receive [ 'PlayOk' ]
[5/4/2021, 8:09:54 PM] DEBUG MMOConnection Connecting [ '127.0.0.1:7777' ]
[5/4/2021, 8:09:54 PM] INFO MMOConnection Connected [ '127.0.0.1:7777' ]
[5/4/2021, 8:09:54 PM] DEBUG GameClient Sending [ 'ProtocolVersion' ]
[5/4/2021, 8:09:54 PM] INFO MMOConnection Disconnected [ '127.0.0.1:2106' ]
[5/4/2021, 8:09:54 PM] DEBUG GameClient Receive [ 'KeyPacket' ]
[5/4/2021, 8:09:54 PM] DEBUG GameClient Sending [ 'AuthLogin' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'CharSelectionInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'CharacterSelect' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SSQInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'CharSelected' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'RequestManorList' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'RequestKeyMapping' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'EnterWorld' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'RequestTargetCancel' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'ValidatePosition' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'MoveBackwardToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'RequestAutoSoulShot' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Sending [ 'Say2' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExSendManorList' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'UserInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExBrExtraUserInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0xe8 0x2] len=8
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ItemList' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExQuestItemList' ]
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0x74 0xd9] len=17
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0xfe 0x84] len=15
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ShortCutInit' ]
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0xfe 0x5f] len=763
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SkillList' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'HennaInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0x86 0x1] len=139
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'RelationChanged' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'CharInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExBrExtraUserInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'RelationChanged' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'NpcInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExSetCompassZoneCode' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'AbnormalStatusUpdate' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'EtcStatusUpdate' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExStorageMaxCount' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'FriendList' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'CreatureSay' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'CreatureSay' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SkillCoolTime' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExVoteSystemInfo' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExNevitAdventPointInfoPacket' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExNevitAdventTimeChange' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ExShowContactList' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'TutorialShowQuestionMark' ]
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0x9e 0x2] len=67
[5/4/2021, 8:09:55 PM] DEBUG GamePacketHandler Unknown game packet received. [0x9e 0x0] len=79
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'TutorialEnableClientEvent' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'ActionFailed' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'CreatureSay' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SocialAction' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
[5/4/2021, 8:09:55 PM] DEBUG GameClient Receive [ 'SocialAction' ]
[5/4/2021, 8:09:56 PM] DEBUG GameClient Receive [ 'SocialAction' ]
[5/4/2021, 8:09:56 PM] DEBUG GameClient Receive [ 'MoveToLocation' ]
I noticed, second account get SocialAction package after Request AuthLogin, is it possible that break login flow of second account? I think some underlying package object may shared between clients is it correct?
[5/4/2021, 8:09:56 PM] DEBUG MMOConnection Connecting [ '127.0.0.1:2106' ]
[5/4/2021, 8:09:56 PM] INFO MMOConnection Connected [ '127.0.0.1:2106' ]
[5/4/2021, 8:09:56 PM] DEBUG Init ProtocolRevision [ 50721 ]
[5/4/2021, 8:09:56 PM] DEBUG LoginClient Receive [ 'Init' ]
[5/4/2021, 8:09:56 PM] DEBUG LoginClient Sending [ 'AuthGameGuard' ]
[5/4/2021, 8:09:56 PM] DEBUG LoginClient Receive [ 'GGAuth' ]
[5/4/2021, 8:09:56 PM] DEBUG LoginClient Sending [ 'RequestAuthLogin' ]
[5/4/2021, 8:09:56 PM] DEBUG GameClient Receive [ 'SocialAction' ]
[5/4/2021, 8:09:56 PM] DEBUG LoginClient Receive [ 'LoginFail' ]
[5/4/2021, 8:09:56 PM] DEBUG GameClient Receive [ 'SystemMessage' ]
[5/4/2021, 8:09:56 PM] DEBUG GameClient Receive [ 'ServerClose' ]