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

92
Views
socket connected but not emit the message

Client-Side: the socket used in website, initially connected and socket id is generated, but when try to emit the message, unable to emit from client to server-side.

<script>
        const socket = io("http://localhost:8080");
        socket.on("connection",() => {
        })
        const socketTrigger = () => {
        console.log("message")
        socket.emit("message", "testing data")
        }
    </script>

Server Side:

    io.on("connection", socket => {
      socket.on("message", (data) => {
        console.log("message", data)
      })
      socket.on("startBidding", isAdminPage => {
      socket.broadcast.emit("startBiddingArray", isAdminPage);
      socket.on("disconnect", () => {
          console.log("Client disconnected");
      });
      });
   })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You just assign a variable with an anonymous function, but you don't call it like: socketTrigger(); at the end of the script.

about 4 years ago · Juan Pablo Isaza 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!