Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6794405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:13:05+00:00 2026-05-26T18:13:05+00:00

I am using Node.js with socket.io to implement websockets in one of my pages.

  • 0

I am using Node.js with socket.io to implement websockets in one of my pages. server.js (what Node.js runs) has this code:

var http = require("http").createServer(),
io = require("socket.io").listen(http);

http.listen(8080);

io.sockets.on("connection", function(socket) {
        socket.emit("message", {hello:"world"});
});

And this is the code I’m trying to connect with:

var socket = new WebSocket("ws://92.60.122.235:8080/");
socket.onopen = function() {  
    alert("Socket has been opened!");  
}

When I load the page, nothing happens. I’m using Chrome, and I know websockets are supported. No errors are present in the error console, and if I watch socket.io serving requests from command line I don’t see any user connecting.

As far as I know this should work, could anyone explain what could be going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:13:06+00:00Added an answer on May 26, 2026 at 6:13 pm

    You need a socket.io client to pass some authentication phases I believe. Try this, and it should work(the client javascript is served by socket.io itself, don’t worry about it).

    <script src="/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost');
      socket.on('message', function (data) {
        console.log(data);
        socket.emit('helloworld', { msg: 'why do you so love to say hello world?' });
      });
    </script>
    

    From http://socket.io/#faq

    Why not just call it WebSocket if the actual WebSocket is not
    present and mimick its API?

    Socket.IO does more than WebSocket, even
    if WebSocket is selected as the transport and the user is browsing
    your website with an ultra modern browser. Certain features like
    heartbeats, timeouts and disconnection support are vital to realtime
    applications but are not provided by the WebSocket API out of the box.

    This is akin to jQuery’s decision of creating a feature-rich and
    simple $.ajax API as opposed to normalizing XMLHttpRequest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement a HTTP server in node.js without using http module. How
I'm interested in using Node.js as a socket server for stream-based communication with tens
I'm doing a simple UDP send using Node's inbuilt datagram UDP socket : http://nodejs.org/docs/v0.3.1/api/dgram.html
I am using a node.js server to create a 'close to real-time' socket between
I've written a TCP server in node.js implementing a binary protocol. Using buffers this
I am using socket.io to connect to my node server using the following script:
When using socket.IO in a Node.js server, is there an easy way to get
I have created a small server for communication using node.js and socket io Server:
using node.js, the net module for building a tcp server which can hande http
How can one select a specific sibling of a context node using jQuery? Specifically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.