Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: Connection Closed" while "requestPairingCode" bug [BUG] #390

Closed
SuhailTechInfo opened this issue Sep 18, 2023 · 26 comments
Closed
Labels
bug Something isn't working

Comments

@SuhailTechInfo
Copy link

Error: Connection Closed
getting while using "requestPairingCode" instead of scanning qr,

Error Connection Closed while equestPairingCode  by SuhailTechInfo

Error while getting Code :
Error: Connection Closed
at sendRawMessage (/home/runner/Baileys-Qr/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:54:19)
at sendNode (/home/runner/Baileys-Qr/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:73:16)
at Object.requestPairingCode (/home/runner/Baileys-Qr/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:370:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
data: null,
isBoom: true,
isServer: false,
output: {
statusCode: 428,
payload: {
statusCode: 428,
error: 'Precondition Required',
message: 'Connection Closed'
},
headers: {}
}
}

@SuhailTechInfo SuhailTechInfo added the bug Something isn't working label Sep 18, 2023
@Guru322
Copy link

Guru322 commented Sep 19, 2023

am also facing this but for me the connection gets established but whenever i try to command in a group it gives the above issue

Note:- i got this issue while running it on cloud environments like Heroku, But works fine on my local pc

This is what my connection options looks like:-

const connectionOptions = { printQRInTerminal: !pairingCode, mobile: useMobile, msgRetryCounterMap, logger: Pino({ level: 'fatal' }), auth: { creds: authState.state.creds, keys: makeCacheableSignalKeyStore(authState.state.keys, Pino().child({ level: 'fatal', stream: 'store' })), }, browser: ['Chrome (Linux)', '', ''], version, getMessage: async (key) => { let jid = jidNormalizedUser(key.remoteJid) let msg = await store.loadMessage(jid, key.id) return msg?.message || "" }, msgRetryCounterCache, connectTimeoutMs: 60000, defaultQueryTimeoutMs: undefined, generateHighQualityLinkPreview: true, syncFullHistory: true, markOnlineOnConnect: true };

@Guru322
Copy link

Guru322 commented Sep 20, 2023

am also facing this but for me the connection gets established but whenever i try to command in a group it gives the above issue

Note:- i got this issue while running it on cloud environments like Heroku, But works fine on my local pc

This is what my connection options looks like:-

const connectionOptions = { printQRInTerminal: !pairingCode, mobile: useMobile, msgRetryCounterMap, logger: Pino({ level: 'fatal' }), auth: { creds: authState.state.creds, keys: makeCacheableSignalKeyStore(authState.state.keys, Pino().child({ level: 'fatal', stream: 'store' })), }, browser: ['Chrome (Linux)', '', ''], version, getMessage: async (key) => { let jid = jidNormalizedUser(key.remoteJid) let msg = await store.loadMessage(jid, key.id) return msg?.message || "" }, msgRetryCounterCache, connectTimeoutMs: 60000, defaultQueryTimeoutMs: undefined, generateHighQualityLinkPreview: true, syncFullHistory: true, markOnlineOnConnect: true };

Ah! it was my skill issue it got Fixed by making defaultQueryTimeoutMs: 0

@Riders004
Copy link

am also facing this but for me the connection gets established but whenever i try to command in a group it gives the above issue
Note:- i got this issue while running it on cloud environments like Heroku, But works fine on my local pc
This is what my connection options looks like:-
const connectionOptions = { printQRInTerminal: !pairingCode, mobile: useMobile, msgRetryCounterMap, logger: Pino({ level: 'fatal' }), auth: { creds: authState.state.creds, keys: makeCacheableSignalKeyStore(authState.state.keys, Pino().child({ level: 'fatal', stream: 'store' })), }, browser: ['Chrome (Linux)', '', ''], version, getMessage: async (key) => { let jid = jidNormalizedUser(key.remoteJid) let msg = await store.loadMessage(jid, key.id) return msg?.message || "" }, msgRetryCounterCache, connectTimeoutMs: 60000, defaultQueryTimeoutMs: undefined, generateHighQualityLinkPreview: true, syncFullHistory: true, markOnlineOnConnect: true };

Ah! it was my skill issue it got Fixed by making defaultQueryTimeoutMs: 0

Have you if you don't have issue so can your pairing code system source code to me

@APdev93
Copy link

APdev93 commented Sep 21, 2023

Check my documentation

https://github.com/ArrDev10/WaBot-With-PairingCode

@Guru322
Copy link

Guru322 commented Sep 22, 2023

Check my documentation

https://github.com/ArrDev10/WaBot-With-PairingCode

IMG_20230922_154938_836
Nice docs brother, simple and helpful

@APdev93
Copy link

APdev93 commented Sep 22, 2023 via email

@Riders004
Copy link

Check my documentation
https://github.com/ArrDev10/WaBot-With-PairingCode

IMG_20230922_154938_836 Nice docs brother, simple and helpful

Have done ?

@Guru322
Copy link

Guru322 commented Sep 22, 2023

does it work well?

On Fri, 22 Sept 2023, 6:22 pm GURU, @.> wrote: Check my documentation https://github.com/ArrDev10/WaBot-With-PairingCode [image: IMG_20230922_154938_836] https://user-images.githubusercontent.com/106463398/269908686-a7b42a98-d935-476e-987b-d4f462b7e570.png Nice docs brother, simple and helpful — Reply to this email directly, view it on GitHub <#390 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT3HFHSEIFX6HIZFAXBCZNDX3VRGNANCNFSM6AAAAAA45B5JJ4 . You are receiving this because you commented.Message ID: @.>

ya it worked too well>,<

@Guru322
Copy link

Guru322 commented Sep 22, 2023

Check my documentation
https://github.com/ArrDev10/WaBot-With-PairingCode

IMG_20230922_154938_836 Nice docs brother, simple and helpful

Have done ?

refer to that docs it will work

@Riders004
Copy link

Check my documentation
https://github.com/ArrDev10/WaBot-With-PairingCode

IMG_20230922_154938_836 Nice docs brother, simple and helpful

Have done ?

refer to that docs it will work

Ah working for me I also done

@APdev93
Copy link

APdev93 commented Sep 22, 2023

Follow may github😂

@Guru322
Copy link

Guru322 commented Sep 23, 2023

Follow may github😂

Oki🗿🗿

@Riders004
Copy link

Follow may github😂

No I saw hisoku Baileys bot

@Jasermon
Copy link

Jasermon commented Sep 27, 2023

Check my documentation

https://github.com/ArrDev10/WaBot-With-PairingCode

I got error from whatsapp. After waited like 5 miniutes, "Something went wrong, please try again later."

const {
  default: makeWASocket,
  useMultiFileAuthState,
  makeCacheableSignalKeyStore,
  fetchLatestBaileysVersion,
} = require("@whiskeysockets/baileys");

const pino = require("pino");
const NodeCache = require("node-cache");
const readline = require("readline");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = require("express")();
const usePairingCode = true;
const useMobile = false;
const useStore = false;

const MAIN_LOGGER = pino({
  timestamp: () => `,"time":"${new Date().toJSON()}"`,
});
const logger = MAIN_LOGGER.child({});
logger.level = "trace";
const store = useStore ? makeInMemoryStore({ logger }) : undefined;
store?.readFromFile("./session");
// Save every 1m
setInterval(() => {
  store?.writeToFile("./session");
}, 10000 * 6);
const msgRetryCounterCache = new NodeCache();
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const question = (text) => new Promise((resolve) => rl.question(text, resolve));

const P = require("pino")({
  level: "silent",
});

app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const server = require("http").createServer(app);
const port = 6580;

app.get("/", (req, res) => {
  res.send("server working");
});

async function connectToWhatsApp() {
  let { state, saveCreds } = await useMultiFileAuthState("session_auth_info");
  let { version, isLatest } = await fetchLatestBaileysVersion();

  const sock = makeWASocket({
    version,
    printQRInTerminal: !usePairingCode,
    auth: {
      creds: state.creds,
      keys: makeCacheableSignalKeyStore(state.keys, P),
    },
    mobile: useMobile,
    logger: P,
    browser: ["chrome (linux)", "", ""],
    msgRetryCounterCache,
    defaultQueryTimeoutMs: 0,
  });
  store?.bind(sock.ev);

  sock.ev.on("creds.update", saveCreds);

  if (usePairingCode && !sock.authState.creds.registered) {
    if (useMobile) {
      throw new Error("cannot use mobile api");
    }
    const phoneNumber = await question("Enter your active whatsapp number: ");
    const code = await sock.requestPairingCode(phoneNumber);
    console.log(`pairing with this code: ${code}`);
  }
}

app.get("/send-message", async (req, res) => {
  const tempMessage = req.query.message;
  const msgTo = req.query.to;

  try {
    if (!msgTo) {
      res.status(500).json({
        status: false,
        response: "The number does not exist",
      });
    } else {
      if (isConnected()) {
        sock
          .sendMessage(msgTo, {
            text: tempMessage,
          })
          .then(() => {
            res.status(200).json({
              status: "success",
              response: "ok",
            });
          })
          .catch((err) => {
            res.status(500).json({
              status: false,
              response: err,
            });
          });
      } else {
        res.status(500).json({
          status: false,
          response: "You are not connected yet",
        });
      }
    }
  } catch (err) {
    res.status(500).send(err);
  }
});

app.get("/get-jid", async (req, res) => {
  const invCode = req.query.code;
  const response = await sock.groupGetInviteInfo(invCode);
  res.status(200).json(response);
});

connectToWhatsApp();
server.listen(port, () => {
  console.log("Server Run Port : " + port);
});

@Riders004
Copy link

Check my documentation
https://github.com/ArrDev10/WaBot-With-PairingCode

I got error from whatsapp. After waited like 5 miniutes, "Something went wrong, please try again later."

const {
  default: makeWASocket,
  useMultiFileAuthState,
  makeCacheableSignalKeyStore,
  fetchLatestBaileysVersion,
} = require("@whiskeysockets/baileys");

const pino = require("pino");
const NodeCache = require("node-cache");
const readline = require("readline");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = require("express")();
const usePairingCode = true;
const useMobile = false;
const useStore = false;

const MAIN_LOGGER = pino({
  timestamp: () => `,"time":"${new Date().toJSON()}"`,
});
const logger = MAIN_LOGGER.child({});
logger.level = "trace";
const store = useStore ? makeInMemoryStore({ logger }) : undefined;
store?.readFromFile("./session");
// Save every 1m
setInterval(() => {
  store?.writeToFile("./session");
}, 10000 * 6);
const msgRetryCounterCache = new NodeCache();
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const question = (text) => new Promise((resolve) => rl.question(text, resolve));

const P = require("pino")({
  level: "silent",
});

app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const server = require("http").createServer(app);
const port = 6580;

app.get("/", (req, res) => {
  res.send("server working");
});

async function connectToWhatsApp() {
  let { state, saveCreds } = await useMultiFileAuthState("session_auth_info");
  let { version, isLatest } = await fetchLatestBaileysVersion();

  const sock = makeWASocket({
    version,
    printQRInTerminal: !usePairingCode,
    auth: {
      creds: state.creds,
      keys: makeCacheableSignalKeyStore(state.keys, P),
    },
    mobile: useMobile,
    logger: P,
    browser: ["chrome (linux)", "", ""],
    msgRetryCounterCache,
    defaultQueryTimeoutMs: 0,
  });
  store?.bind(sock.ev);

  sock.ev.on("creds.update", saveCreds);

  if (usePairingCode && !sock.authState.creds.registered) {
    if (useMobile) {
      throw new Error("cannot use mobile api");
    }
    const phoneNumber = await question("Enter your active whatsapp number: ");
    const code = await sock.requestPairingCode(phoneNumber);
    console.log(`pairing with this code: ${code}`);
  }
}

app.get("/send-message", async (req, res) => {
  const tempMessage = req.query.message;
  const msgTo = req.query.to;

  try {
    if (!msgTo) {
      res.status(500).json({
        status: false,
        response: "The number does not exist",
      });
    } else {
      if (isConnected()) {
        sock
          .sendMessage(msgTo, {
            text: tempMessage,
          })
          .then(() => {
            res.status(200).json({
              status: "success",
              response: "ok",
            });
          })
          .catch((err) => {
            res.status(500).json({
              status: false,
              response: err,
            });
          });
      } else {
        res.status(500).json({
          status: false,
          response: "You are not connected yet",
        });
      }
    }
  } catch (err) {
    res.status(500).send(err);
  }
});

app.get("/get-jid", async (req, res) => {
  const invCode = req.query.code;
  const response = await sock.groupGetInviteInfo(invCode);
  res.status(200).json(response);
});

connectToWhatsApp();
server.listen(port, () => {
  console.log("Server Run Port : " + port);
});

Refersh your browser or removed old session

@Riders004
Copy link

/

@Jasermon
Copy link

Check my documentation
https://github.com/ArrDev10/WaBot-With-PairingCode

I got error from whatsapp. After waited like 5 miniutes, "Something went wrong, please try again later."

const {
  default: makeWASocket,
  useMultiFileAuthState,
  makeCacheableSignalKeyStore,
  fetchLatestBaileysVersion,
} = require("@whiskeysockets/baileys");

const pino = require("pino");
const NodeCache = require("node-cache");
const readline = require("readline");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = require("express")();
const usePairingCode = true;
const useMobile = false;
const useStore = false;

const MAIN_LOGGER = pino({
  timestamp: () => `,"time":"${new Date().toJSON()}"`,
});
const logger = MAIN_LOGGER.child({});
logger.level = "trace";
const store = useStore ? makeInMemoryStore({ logger }) : undefined;
store?.readFromFile("./session");
// Save every 1m
setInterval(() => {
  store?.writeToFile("./session");
}, 10000 * 6);
const msgRetryCounterCache = new NodeCache();
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const question = (text) => new Promise((resolve) => rl.question(text, resolve));

const P = require("pino")({
  level: "silent",
});

app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const server = require("http").createServer(app);
const port = 6580;

app.get("/", (req, res) => {
  res.send("server working");
});

async function connectToWhatsApp() {
  let { state, saveCreds } = await useMultiFileAuthState("session_auth_info");
  let { version, isLatest } = await fetchLatestBaileysVersion();

  const sock = makeWASocket({
    version,
    printQRInTerminal: !usePairingCode,
    auth: {
      creds: state.creds,
      keys: makeCacheableSignalKeyStore(state.keys, P),
    },
    mobile: useMobile,
    logger: P,
    browser: ["chrome (linux)", "", ""],
    msgRetryCounterCache,
    defaultQueryTimeoutMs: 0,
  });
  store?.bind(sock.ev);

  sock.ev.on("creds.update", saveCreds);

  if (usePairingCode && !sock.authState.creds.registered) {
    if (useMobile) {
      throw new Error("cannot use mobile api");
    }
    const phoneNumber = await question("Enter your active whatsapp number: ");
    const code = await sock.requestPairingCode(phoneNumber);
    console.log(`pairing with this code: ${code}`);
  }
}

app.get("/send-message", async (req, res) => {
  const tempMessage = req.query.message;
  const msgTo = req.query.to;

  try {
    if (!msgTo) {
      res.status(500).json({
        status: false,
        response: "The number does not exist",
      });
    } else {
      if (isConnected()) {
        sock
          .sendMessage(msgTo, {
            text: tempMessage,
          })
          .then(() => {
            res.status(200).json({
              status: "success",
              response: "ok",
            });
          })
          .catch((err) => {
            res.status(500).json({
              status: false,
              response: err,
            });
          });
      } else {
        res.status(500).json({
          status: false,
          response: "You are not connected yet",
        });
      }
    }
  } catch (err) {
    res.status(500).send(err);
  }
});

app.get("/get-jid", async (req, res) => {
  const invCode = req.query.code;
  const response = await sock.groupGetInviteInfo(invCode);
  res.status(200).json(response);
});

connectToWhatsApp();
server.listen(port, () => {
  console.log("Server Run Port : " + port);
});

Refersh your browser or removed old session

Browser? I start the script from the terminal section in VSCode with "yarn start". I enter the code from my phone. And of course I delete the old session.

@Riders004
Copy link

Check my documentation
https://github.com/ArrDev10/WaBot-With-PairingCode

I got error from whatsapp. After waited like 5 miniutes, "Something went wrong, please try again later."

const {
  default: makeWASocket,
  useMultiFileAuthState,
  makeCacheableSignalKeyStore,
  fetchLatestBaileysVersion,
} = require("@whiskeysockets/baileys");

const pino = require("pino");
const NodeCache = require("node-cache");
const readline = require("readline");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = require("express")();
const usePairingCode = true;
const useMobile = false;
const useStore = false;

const MAIN_LOGGER = pino({
  timestamp: () => `,"time":"${new Date().toJSON()}"`,
});
const logger = MAIN_LOGGER.child({});
logger.level = "trace";
const store = useStore ? makeInMemoryStore({ logger }) : undefined;
store?.readFromFile("./session");
// Save every 1m
setInterval(() => {
  store?.writeToFile("./session");
}, 10000 * 6);
const msgRetryCounterCache = new NodeCache();
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const question = (text) => new Promise((resolve) => rl.question(text, resolve));

const P = require("pino")({
  level: "silent",
});

app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const server = require("http").createServer(app);
const port = 6580;

app.get("/", (req, res) => {
  res.send("server working");
});

async function connectToWhatsApp() {
  let { state, saveCreds } = await useMultiFileAuthState("session_auth_info");
  let { version, isLatest } = await fetchLatestBaileysVersion();

  const sock = makeWASocket({
    version,
    printQRInTerminal: !usePairingCode,
    auth: {
      creds: state.creds,
      keys: makeCacheableSignalKeyStore(state.keys, P),
    },
    mobile: useMobile,
    logger: P,
    browser: ["chrome (linux)", "", ""],
    msgRetryCounterCache,
    defaultQueryTimeoutMs: 0,
  });
  store?.bind(sock.ev);

  sock.ev.on("creds.update", saveCreds);

  if (usePairingCode && !sock.authState.creds.registered) {
    if (useMobile) {
      throw new Error("cannot use mobile api");
    }
    const phoneNumber = await question("Enter your active whatsapp number: ");
    const code = await sock.requestPairingCode(phoneNumber);
    console.log(`pairing with this code: ${code}`);
  }
}

app.get("/send-message", async (req, res) => {
  const tempMessage = req.query.message;
  const msgTo = req.query.to;

  try {
    if (!msgTo) {
      res.status(500).json({
        status: false,
        response: "The number does not exist",
      });
    } else {
      if (isConnected()) {
        sock
          .sendMessage(msgTo, {
            text: tempMessage,
          })
          .then(() => {
            res.status(200).json({
              status: "success",
              response: "ok",
            });
          })
          .catch((err) => {
            res.status(500).json({
              status: false,
              response: err,
            });
          });
      } else {
        res.status(500).json({
          status: false,
          response: "You are not connected yet",
        });
      }
    }
  } catch (err) {
    res.status(500).send(err);
  }
});

app.get("/get-jid", async (req, res) => {
  const invCode = req.query.code;
  const response = await sock.groupGetInviteInfo(invCode);
  res.status(200).json(response);
});

connectToWhatsApp();
server.listen(port, () => {
  console.log("Server Run Port : " + port);
});

Refersh your browser or removed old session

Browser? I start the script from the terminal section in VSCode with "yarn start". I enter the code from my phone. And of course I delete the old session.

As far as I understand, this is the code for Pairing Code generation or in your web intersect but there is no option to enter mobile number anywhere and option to get Pairing code. Just use without web or if you can make it web based then do it

@Jasermon
Copy link

Jasermon commented Sep 27, 2023

As far as I understand, this is the code for Pairing Code generation or in your web intersect but there is no option to enter mobile number anywhere and option to get Pairing code. Just use without web or if you can make it web based then do it

https://i.imgur.com/BJKM0Tj.png

I am not using the web part to connect WhatsApp.

@Teamolduser
Copy link

As far as I understand, this is the code for Pairing Code generation or in your web intersect but there is no option to enter mobile number anywhere and option to get Pairing code. Just use without web or if you can make it web based then do it

https://i.imgur.com/BJKM0Tj.png

I am not using the web part to connect WhatsApp.

Then

@malwareslayer
Copy link

Its because the websockets instance not finishing set up to send ephemeral client hello since the constructor makeWASocket are not asynchronous, you could use delay to waiting the socket sending the ephemeral first

Your trace log should be like this in order to sucessfull

{"level":10,"time":1697649404017,"pid":748691,"hostname":"archlinux","handshake":{"serverHello":{"ephemeral":"6OBLMwks3eVFlY/odKx1A5dcEqLVH8LJcaaYWBDb23U=","static":"8im02hGbz2PD3+qfMSA9DaiASps+8tuPjWQDErilm8RW1XUMdLyc3hYk748cpxlH","payload":"GkEHxnKUlr/djzI15gvuco+UqK7sjsd1tKEQm8IGcLdQDtNOl1cqiAbqdOViluy316VyWnOG9MHgs/I5FP8DbcXQr1VWpnc0dJbh2SuzJCSL1q5ziZzaIcCmgsq8K3muID4bqlhPDAH1gJN2VL8xFghMe8H2aoHRS/NR/8UBVyY8tNTDAB2vzFnqMXn9HN9mmawk3ojpHhWtYn+fM+MXQIfAUpDZrRw4oAuODQioIlZqJ8Wc5wdjMklVVM6b9bk+JzjKWXY46rI6E63+R+F4A0gqhndwadGyEq3x16DFA2d0cjznfdPXTiHkK/H1oggsAfS016sZg2ND7XI1OGgVlnw="}},"msg":"handshake recv from WA"}
{"level":30,"time":1697649404020,"pid":748691,"hostname":"archlinux","node":{"passive":false,"userAgent":{"platform":"MACOS","appVersion":{"primary":2,"secondary":2329,"tertiary":9},"mcc":"000","mnc":"000","osVersion":"0.1","manufacturer":"","device":"Desktop","osBuildNumber":"0.1","releaseChannel":"RELEASE","localeLanguageIso6391":"en","localeCountryIso31661Alpha2":"US"},"connectType":"WIFI_UNKNOWN","connectReason":"USER_ACTIVATED","devicePairingData":{"eRegid":"AAAAUg==","eKeytype":"BQ==","eIdent":"KWgFeuE8csBUK2+VCQAw7Z6lffQUc+aB967MoqPQlDw=","eSkeyId":"AAAB","eSkeyVal":"0VXkdWWnxSmsUDSvoUL/ondFWScPNyc+WYjLfVbRMEE=","eSkeySig":"/YqVAA2BWU37B+LC6gQ8bMSCZSKjzeEHzX9AxBQiILo0kI4U06JdEDlRB6PSfnQYSUjZxTT8aYJDUEg5TE72iw==","buildHash":"CgVgtSpHoPZPkgJcSCwM7A==","deviceProps":"ChVHb29nbGUgQ2hyb21lIChMaW51eCkYByAA"}},"msg":"not logged in, attempting registration..."}
{"level":10,"time":1697649404364,"pid":748691,"hostname":"archlinux","class":"ns","msg":"recv 607 bytes, total recv 607 bytes"}
{"level":10,"time":1697649404365,"pid":748691,"hostname":"archlinux","class":"ns","msg":"2600667233","msg":"recv frame"}
{"level":10,"time":1697649404365,"pid":748691,"hostname":"archlinux","msg":"<iq from='@s.whatsapp.net' type='set' id='2600667233' xmlns='md'>\n\t\t<pair-device >\n\t\t\t\t<ref >\n\t\t\t\t\t32404b3564484938422f327570556a77746130784e3758474c4749412b6a38562f5544674771426b3977617775472f4b552f7230314e7033466c4e626b553431464b326c38334531433144446d4b2f773d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t32404b766162625469342f73414f34657a785037326c46316a4f333577636f4e61627a496b486f4a6f48736a454a626c66332b5744666f6477736a593738764e48656a64754c6853396a706f723372673d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t32404a474e6a2b58433164336f6a7147516b74516167342f3141344a542f6973786f4148573956794a46494c4755597641674b6b39696a5635614c2f596170457a4242766931387076742f732f387a673d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t324037753146494668426573687362386a784346395762774c3174425649412f53586242574c6d666f5452676d4b6372736a3274466f384a3742713145423265585677544437676a69444c77304137673d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t32405079394d303572667437573346744e4d4448645331695a4f61734264496930776e416d7951564e58456d3649386974466e316f77644f2f786d784167556e3537785769484b6b48476f6a514a47773d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t324077596b416f6479645047484f6a4d4d47456b7049634642584c38676235426c534a306f4d6d6f342b55664b48634f762f4c65367a74504642476c354d3261347678397241656432357a476b5843673d3d\n\t\t\t\t</ref>\n\t\t</pair-device>\n</iq>"}
{"level":10,"time":1697649404365,"pid":748691,"hostname":"archlinux","msg":"<iq to='@s.whatsapp.net' type='result' id='2600667233'/>"}
{"level":10,"time":1697649406202,"pid":748691,"hostname":"archlinux","msg":"<iq to='@s.whatsapp.net' type='set' id='30934.23729-1' xmlns='md'>\n\t\t<link_code_companion_reg jid='+6288976384600@s.whatsapp.net' stage='companion_hello' should_show_push_notification='true'>\n\t\t\t\t<link_code_pairing_wrapped_companion_ephemeral_pub >\n\t\t\t\t\t3ccab27c683722af4635353e3a7f398313070ab5c279ec4f45b07743975b6ff9423a7ee82ad50779e4dd29e3b1f3aa9a5fe9472f418c8b79099073d5efd88f98a9e3934300f858348e6074d8e5ee4d27\n\t\t\t\t</link_code_pairing_wrapped_companion_ephemeral_pub>\n\t\t\t\t<companion_server_auth_key_pub >\n\t\t\t\t\t64c7a30a149c50fd634869c09f0770dd00750b4ce350c22135673be486f2113e\n\t\t\t\t</companion_server_auth_key_pub>\n\t\t\t\t<companion_platform_id >\n\t\t\t\t\t49\n\t\t\t\t</companion_platform_id>\n\t\t\t\t<companion_platform_display >\n\t\t\t\t\tGoogle Chrome (Linux)\n\t\t\t\t</companion_platform_display>\n\t\t\t\t<link_code_pairing_nonce >\n\t\t\t\t\t0\n\t\t\t\t</link_code_pairing_nonce>\n\t\t</link_code_companion_reg>\n</iq>"}
2T93HRW7

@Riders004
Copy link

@Guru322 bro web based Pairing code dedo 🥺

@Guru322
Copy link

Guru322 commented Dec 4, 2023

@SuhailTechInfo close this issue

@Riders004
Copy link

@SuhailTechInfo close this issue

Dedo yr 😭😭

@SuhailTechInfo
Copy link
Author

well i solved my issue by following code !
`const Suhail_Md = Suhail_DefaultSocket({
logger: Pino({ level: "silent" }).child({ level: "silent" }),
printQRInTerminal: false,
auth: {
creds: state.creds,
keys: makeCacheableSignalKeyStore(state.keys, Pino({ level: "silent" }).child({ level: "silent" })),
},
browser: ['Chrome (Linux)', '', ''],
getMessage: async (key) => {
let jid = jidNormalizedUser(key.remoteJid)
let msg = await store.loadMessage(jid, key.id)

  return msg?.message || ""
},
msgRetryCounterCache,
defaultQueryTimeoutMs: undefined,

})`

@swagisays
Copy link

Its because the websockets instance not finishing set up to send ephemeral client hello since the constructor makeWASocket are not asynchronous, you could use delay to waiting the socket sending the ephemeral first

Your trace log should be like this in order to sucessfull

{"level":10,"time":1697649404017,"pid":748691,"hostname":"archlinux","handshake":{"serverHello":{"ephemeral":"6OBLMwks3eVFlY/odKx1A5dcEqLVH8LJcaaYWBDb23U=","static":"8im02hGbz2PD3+qfMSA9DaiASps+8tuPjWQDErilm8RW1XUMdLyc3hYk748cpxlH","payload":"GkEHxnKUlr/djzI15gvuco+UqK7sjsd1tKEQm8IGcLdQDtNOl1cqiAbqdOViluy316VyWnOG9MHgs/I5FP8DbcXQr1VWpnc0dJbh2SuzJCSL1q5ziZzaIcCmgsq8K3muID4bqlhPDAH1gJN2VL8xFghMe8H2aoHRS/NR/8UBVyY8tNTDAB2vzFnqMXn9HN9mmawk3ojpHhWtYn+fM+MXQIfAUpDZrRw4oAuODQioIlZqJ8Wc5wdjMklVVM6b9bk+JzjKWXY46rI6E63+R+F4A0gqhndwadGyEq3x16DFA2d0cjznfdPXTiHkK/H1oggsAfS016sZg2ND7XI1OGgVlnw="}},"msg":"handshake recv from WA"}
{"level":30,"time":1697649404020,"pid":748691,"hostname":"archlinux","node":{"passive":false,"userAgent":{"platform":"MACOS","appVersion":{"primary":2,"secondary":2329,"tertiary":9},"mcc":"000","mnc":"000","osVersion":"0.1","manufacturer":"","device":"Desktop","osBuildNumber":"0.1","releaseChannel":"RELEASE","localeLanguageIso6391":"en","localeCountryIso31661Alpha2":"US"},"connectType":"WIFI_UNKNOWN","connectReason":"USER_ACTIVATED","devicePairingData":{"eRegid":"AAAAUg==","eKeytype":"BQ==","eIdent":"KWgFeuE8csBUK2+VCQAw7Z6lffQUc+aB967MoqPQlDw=","eSkeyId":"AAAB","eSkeyVal":"0VXkdWWnxSmsUDSvoUL/ondFWScPNyc+WYjLfVbRMEE=","eSkeySig":"/YqVAA2BWU37B+LC6gQ8bMSCZSKjzeEHzX9AxBQiILo0kI4U06JdEDlRB6PSfnQYSUjZxTT8aYJDUEg5TE72iw==","buildHash":"CgVgtSpHoPZPkgJcSCwM7A==","deviceProps":"ChVHb29nbGUgQ2hyb21lIChMaW51eCkYByAA"}},"msg":"not logged in, attempting registration..."}
{"level":10,"time":1697649404364,"pid":748691,"hostname":"archlinux","class":"ns","msg":"recv 607 bytes, total recv 607 bytes"}
{"level":10,"time":1697649404365,"pid":748691,"hostname":"archlinux","class":"ns","msg":"2600667233","msg":"recv frame"}
{"level":10,"time":1697649404365,"pid":748691,"hostname":"archlinux","msg":"<iq from='@s.whatsapp.net' type='set' id='2600667233' xmlns='md'>\n\t\t<pair-device >\n\t\t\t\t<ref >\n\t\t\t\t\t32404b3564484938422f327570556a77746130784e3758474c4749412b6a38562f5544674771426b3977617775472f4b552f7230314e7033466c4e626b553431464b326c38334531433144446d4b2f773d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t32404b766162625469342f73414f34657a785037326c46316a4f333577636f4e61627a496b486f4a6f48736a454a626c66332b5744666f6477736a593738764e48656a64754c6853396a706f723372673d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t32404a474e6a2b58433164336f6a7147516b74516167342f3141344a542f6973786f4148573956794a46494c4755597641674b6b39696a5635614c2f596170457a4242766931387076742f732f387a673d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t324037753146494668426573687362386a784346395762774c3174425649412f53586242574c6d666f5452676d4b6372736a3274466f384a3742713145423265585677544437676a69444c77304137673d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t32405079394d303572667437573346744e4d4448645331695a4f61734264496930776e416d7951564e58456d3649386974466e316f77644f2f786d784167556e3537785769484b6b48476f6a514a47773d3d\n\t\t\t\t</ref>\n\t\t\t\t<ref >\n\t\t\t\t\t324077596b416f6479645047484f6a4d4d47456b7049634642584c38676235426c534a306f4d6d6f342b55664b48634f762f4c65367a74504642476c354d3261347678397241656432357a476b5843673d3d\n\t\t\t\t</ref>\n\t\t</pair-device>\n</iq>"}
{"level":10,"time":1697649404365,"pid":748691,"hostname":"archlinux","msg":"<iq to='@s.whatsapp.net' type='result' id='2600667233'/>"}
{"level":10,"time":1697649406202,"pid":748691,"hostname":"archlinux","msg":"<iq to='@s.whatsapp.net' type='set' id='30934.23729-1' xmlns='md'>\n\t\t<link_code_companion_reg jid='+6288976384600@s.whatsapp.net' stage='companion_hello' should_show_push_notification='true'>\n\t\t\t\t<link_code_pairing_wrapped_companion_ephemeral_pub >\n\t\t\t\t\t3ccab27c683722af4635353e3a7f398313070ab5c279ec4f45b07743975b6ff9423a7ee82ad50779e4dd29e3b1f3aa9a5fe9472f418c8b79099073d5efd88f98a9e3934300f858348e6074d8e5ee4d27\n\t\t\t\t</link_code_pairing_wrapped_companion_ephemeral_pub>\n\t\t\t\t<companion_server_auth_key_pub >\n\t\t\t\t\t64c7a30a149c50fd634869c09f0770dd00750b4ce350c22135673be486f2113e\n\t\t\t\t</companion_server_auth_key_pub>\n\t\t\t\t<companion_platform_id >\n\t\t\t\t\t49\n\t\t\t\t</companion_platform_id>\n\t\t\t\t<companion_platform_display >\n\t\t\t\t\tGoogle Chrome (Linux)\n\t\t\t\t</companion_platform_display>\n\t\t\t\t<link_code_pairing_nonce >\n\t\t\t\t\t0\n\t\t\t\t</link_code_pairing_nonce>\n\t\t</link_code_companion_reg>\n</iq>"}
2T93HRW7

Where to add delay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants