Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
Web socket.io con AdonisJs no funciona correctamente

Web socket.io con AdonisJs no funciona correctamente.

Estoy usando una lib para realizar tareas dentro de adonis, adonis5-scheduler.

A continuación se muestra mi tarea.

 import { BaseTask } from 'adonis5-scheduler/build' export default class GetRouletteGame extends BaseTask { public static get schedule() { return '*/3 * * * * *' } /** * Set enable use .lock file for block run retry task * Lock file save to `build/tmpTaskLock` */ public static get useLock() { return false } public async handle() { Ws.io.emit(`taskName`, 1) console.log('ok') } }

A continuación se muestra mi Ws.

 import { Server } from 'socket.io' import AdonisServer from '@ioc:Adonis/Core/Server' class Ws { public io: Server private booted = false public boot() { /** * Ignore multiple calls to the boot method */ if (this.booted) { return } this.booted = true this.io = new Server(AdonisServer.instance!, { cors: { origin: '*' } }) } } export default new Ws()

Llamar a Ws.io.emit desde el controlador funciona.

Llamar a Ws.io.emit desde la tarea no funciona.

Nota para la tarea Ws.io.emit no funciona, sin embargo, console.log muestra el mensaje.

La tarea no ejecuta Ws.io.emit

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Resuelto

await fetch('http://127.0.0.1:3333/endpoint' para controlar

Desde el controlador llamé a emit y funcionó.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!