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 7668863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:27:55+00:00 2026-05-31T15:27:55+00:00

I am developing a small app in Node.js. I am just using Node.js for

  • 0

I am developing a small app in Node.js. I am just using Node.js for input and output. The actual website is just running through nginx. The website has a Websocket connection with node.js and is primarily used for db manipulations.

One of the things I am trying to do is get node to send small pieces of html along with the data from the database. I tried the following code.

simplified:

    connection.on('message', function(message) {
        fs.readFile(__dirname + '/views/user.html', function(err, html){

            if(err){
                console.log(err);
            }else{
                connection.sendUTF( JSON.stringify({
                    content: html,
                    data: {}
                }));
            }
        });
    }
});

When I console.log(html) on the server or in the client I only get numbers back.

Anyone know what could be wrong.

NOTE: I really want to stay away from stuff like socket.io, express, etc. Just keeping it as simple as possible and no fallbacks are needed.

  • 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-31T15:27:57+00:00Added an answer on May 31, 2026 at 3:27 pm

    If you don’t specify an encoding for fs.readFile, you will retrieve the raw buffer instead of the expected file contents.

    Try calling it this way:

    fs.readFile(__dirname + '/views/user.html', 'utf8', function(err, html){
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PyGTK for a small app I've developing. The usage of URLlib2 through
I am developing a small app for a Motorola 9090-G using .net compact framework
I am developing a small app under Linux using the CodeBlocks IDE. I have
I am developing a facebook app using php SDK, my app is small and
I have just started having a go at developing a small KDE app as
I am developing a small scale app using smart gwt 2.4. I chose smart
I am developing a small web app. There isn't any advanced functionality, just basic
I am developing a small game app using Uikit + Uiimages . In the
I am developing a web app but running into a few small snags. I'm
I am developing a small app using jquery mobile. I have the following scenario

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.