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

  • Home
  • SEARCH
  • 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 7815573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:33:47+00:00 2026-06-02T05:33:47+00:00

I have a running server with apache and Socket.IO. I’m trying to send and

  • 0

I have a running server with apache and Socket.IO. I’m trying to send and receive message using socket.io on my website.

This is the code of my server:

var fs = require('fs');
var hskey = fs.readFileSync('file.key');
var hscert = fs.readFileSync('file.crt');

var options = {
    key: hskey,
    cert: hscert
};

var app = require('https').createServer(options);
var io = require('/usr/local/lib/node_modules/socket.io').listen(app);

app.listen(8181);

io.sockets.on('connection', function (socket) {
  socket.emit('serverMessage', 'Bienvenue master!');
socket.broadcast.emit('serverMessage', 'New user online');
});

And this is the webpage:

<!doctype html>
<html>
  <head>
    <title>Socket.io Test</title>
    <script src="./socket.io.js"></script>
  </head>
  <body>

    <script>

    var socket;
    var firstconnect = true;

    function connect() {
      if(firstconnect) {
        socket = io.connect('https://secure.mysite.com:8181');

        socket.on('serverMessage', function(data){ message(data); });
        socket.on('connect', function(){ status_update("Connected to Server"); });
        socket.on('disconnect', function(){ status_update("Disconnected from Server"); });
        socket.on('reconnect', function(){ status_update("Reconnected to Server"); });
        socket.on('reconnecting', function( nextRetry ){ status_update("Reconnecting in " 
          + nextRetry + " seconds"); });
        socket.on('reconnect_failed', function(){ message("Reconnect Failed"); });

        firstconnect = false;
      }
      else {
        socket.socket.reconnect();
      }
    }

    function disconnect() {
      socket.disconnect();
    }

    function message(data) {
      document.getElementById('message').innerHTML += "<br>" + "Server says: " + data;
    }

    function status_update(txt){
      document.getElementById('status').innerHTML = txt;
    }

    function esc(msg){
      return msg.replace(/</g, '&lt;').replace(/>/g, '&gt;');
    }

    function send() {
      socket.send('clientMessage', 'world');    
    };        

    </script>

    <h1>Socket.io Test</h1>
    <div><p id="status">Waiting for input</p></div>
    <div><p id="message"></p></div>  
    <button id="connect" onClick='connect()'/>Connect</button>
    <button id="disconnect" onClick='disconnect()'>Disconnect</button>
    <button id="send" onClick='send()'/>Send Message</button>
  </body>
</html>

Everything seems to work fine under Safari (websocket) and Opera (json pooling) but with Firefox and Chrome (websocket) I cannot send any message from the client to the server. Everything else is working, I can handshake, connect and gets server messages. I made allot of research but seems like I’m the only one with this problem.

Thanks for helping me!

  • 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-06-02T05:33:50+00:00Added an answer on June 2, 2026 at 5:33 am

    I found the problem, I was using a different version of socket.io.js then the server side.

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

Sidebar

Related Questions

I have an Apache server running which hosts a php web application. This server
This error has been driving me nuts. We have a server running Apache and
On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts
I have my Apache http server running on localhost:80 and restlet server on localhost:8182,
I have Apache 2 running on a VPS server (running Debian). I recently changed
I have a server running Gentoo 2.6.12 r6 and I want to run Apache
I'm running an Apache server (v2.2.10) with mod_python, Python 2.5 and Django. I have
I have Apache running on a public-facing Debian server, and am a bit worried
I have Apache/SVN running on Windows Server 2003 with authentication via LDAP/Active Directory and
I have two servers: Fedora running Apache/2.2.14 (old server) CentOs running Apache/2.2.3 (new server)

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.