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

507
Views
JavaScript websocket.emit TypeError: socket.emit is not a function

I would like to emit special event from client side to server. I created a code like this :

const socket = new WebSocket('ws://localhost:9090');

let set_nickname = message => {
    socket.emit ("type-event",message)
}

It throws an error:

Uncaught TypeError: socket.emit is not a function

I couldn't find a solution due to this problem (I'm not sure if emit is even implemented in websocket, I couldn't find a method in a specification, but webstorm suggests that I could use this).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The .emit() is a part of Socket.IO but you are using WebSocket API in a browser that uses .send() to emit data to server.

const socket = new WebSocket('ws://localhost:9090');

socket.send("Hello server!");
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!