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

113
Views
Is it possible to send a ping opcode using javascript Websocket?

I have a websocket client and I want it to send a ping frame to my WS server. According to the RFC 6455 a ping frame is represented by opcode %x9 but I don't know if it's even possible to send from a browser.

Any help will be appreciated

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

0

Building on-top of the comments in your original post, you can manually send pings via websocket.

The link by Daniel W. of the ws library has a ping() method which can be called from a valid websocket client. See an example here.

If you have written your own websocket library then you must conform to the standard framing outlined in RFC6455 The Websocket Protocol.

You should be able to pack a buffer with the correct header and control opcode and send it over the upgraded HTTP1.1 TCP connection.

Edit:
Further research shows, at the point of writing, the Ping method is not supported via the native Websocket Client and the send method seems to only support payloads and not command messages, which include opcodes for commands such as ping.

An option could be to go with a WASM based solution which could make non-XHR or non-fetch based TCP connections, however this comes with a whole different set of challenges.

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!