Why can my JavaScript server code read "2011" but not "20,11" when both are formatted as strings?

Currently, I am trying to establish a connection between Storm and JavaScript through redis. While the redis aspect of the connection is functioning correctly, I am encountering an issue when attempting to publish tuples (essentially Strings). Even though redis successfully receives the tuples, my code (which is slightly modified from an example found online) fails to receive anything. Below is the snippet of my code:

/*
    Node.js server script
    Required node packages: express, redis, socket.io
*/
const PORT = 3000;
const HOST = 'localhost';

var express = require('express'),
    http = require('http'), 
    server = http.createServer(app);
    log('info', 'connected to express');
var app = express();

const redis = require('redis');
const client = redis.createClient();
log('info', 'connected to redis server');

const io = require('socket.io');

if (!module.parent) {
    server.listen(PORT, HOST);
    const socket  = io.listen(server);

    socket.on('connection', function(client) {
        const subscribe = redis.createClient()
        subscribe.subscribe('realtime');

        subscribe.on("message", function(channel, message) {
            client.send(message);
            log('msg', "received from channel #" + channel + " : " + message);
        });

        client.on('message', function(msg) {
            log('debug', msg);
        });

        client.on('disconnect', function() {
            log('warn', 'disconnecting from redis');
            subscribe.quit();
        });
    });
}

function log(type, msg) {

    var color   = '\u001b[0m',
        reset = '\u001b[0m';

    switch(type) {
        case "info":
            color = '\u001b[36m';
            break;
        case "warn":
            color = '\u001b[33m';
            break;
        case "error":
            color = '\u001b[31m';
            break;
        case "msg":
            color = '\u001b[34m';
            break;
        default:
            color = '\u001b[0m'
    }

    console.log(color + '   ' + type + '  - ' + reset + msg);
}

Whenever I send integers, the terminal displays the message correctly, but it fails with tuples. I have minimal experience with JavaScript, hence struggling to understand why it cannot process tuples in the same manner as integers.

Your assistance will be highly appreciated.

Answer №1

Before the messages I sent were split in the treatment process at Redis, but now they are not and the messages reach the client successfully.

Appreciate all the responses!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for adding extra spacing between icon and text field using Vuetify

The code snippet below is used for the username section: <v-text-field prepend-icon="fas fa-user" height="60px" placeholder="Username" outlined ></v-text-field> Is there a way to add space between the user ...

Preserve the content in the text box corresponding to the selected radio button

In my form, there are multiple radio buttons, each with an associated text box value. Users can only select one radio button at a time and submit the form. However, sometimes users will enter data in a textbox for one radio button, then switch to another o ...

Tips for transferring HTML code to a controller

Currently facing an issue while working with MVC and attempting to store HTML code from a view in a database field. In the JS section of my MVC solution, I have the following code snippet: var data = { id_perizia: $("#id_perizia").val(), pinSessione: $("# ...

How to use jQuery Animate to create a step-by-step animation with image sprites?

I'm working on creating an image sprite using jQuery and I'm curious if it's feasible to animate it in steps rather than a linear motion. I initially tried using CSS3 animations, but since IE9 is a requirement, the animations didn't wor ...

A step-by-step guide on effectively implementing express-session with firebase cloud functions

Hello, I am currently working on using express sessions for my backend deployed to Firebase cloud functions. I'm facing an issue where data related to the current session isn't being saved properly. When I try to save something using req.session. ...

Failure to populate AngularJS view

I am a beginner in AngularJS and I am attempting to create a page similar to the example provided here. While the example works perfectly when copied from the link above, I am facing difficulties trying to integrate it into my folder structure as displaye ...

Can one controller in a mean stack handle two models concurrently?

Exploring the world of MEAN STACK and tackling a project related to user entry and exit has presented me with an interesting challenge. Each user's username is stored in a separate collection, prompting me to consider creating 2 models within a single ...

Is it possible to retrieve a specific property from an object in JSON format using Javascript?

As a beginner in JavaScript, I've been diving into the world of objects and trying to grasp how they function. var data = JSON.stringify({name: "Y", age: 1990}); console.log(data); // → {"name":"Y","age":1990} Out of sheer curiosity, I decided to ...

Error encountered when attempting to delete a file with unlink due to the EBUSY condition

Describing a delete route that removes an image file, the following code is provided: router.delete('/:id', (req, res) => { let pathForThumb = ''; let pathForImage = ''; Image.findOne({ _id: req.params.id }) ...

Obtaining a substantial pdf file using html2pdf

While using html2pdf to generate a PDF of my website, I noticed that the downloaded PDF ends up being 14 pages long. However, after approximately 12 pages, all the colored elements seem to disappear. On mobile screens, this issue occurs even sooner, around ...

In Firefox, long strings are automatically truncated, while in Google Chrome they display perfectly without any truncation

Here is a block of code where I am using a web service to retrieve a JSON string. It is encapsulated in an XML tag, which I then read and parse with jQuery's parser jQuery.parseJSON(xml.getElementsByTagName("string")[0].firstChild.nodeValue); $.ajax ...

The persistentFilter in the Tabulator is failing to verify for the headerFilterEmptyCheck

Using Tabulator version 4.4.3 When filtering the checkbox in the usual way, everything works fine. If I set a filtered checkbox to true on a column, it functions correctly: headerFilterEmptyCheck: function (value) { return !value; }, Howev ...

The favicon appears broken upon opening a new tab

Usually, I use a favicon PNG file for my website. It works perfectly and I can see my favicon on the browser tab. However, when I open a PDF document in a new page from my Angular app, I notice that there is a broken icon on the browser tab. Here is how I ...

What could be causing the issue with my connection.query when using mysql in node.js?

Purpose: The goal is to perform a basic query on the database. Expected Outcome: The console should display "please print something!" along with the results of the query. Actual Outcome: Sadly, nothing appears on the terminal screen. Issues: No error me ...

What could be causing npm to fail to launch?

Whenever I execute node app.js, my server functions perfectly. However, when attempting to utilize nodemon for running the server, it fails to start. The error displayed by npm start is as follows: npm ERR! code ELIFECYCLE npm ERR! errno 9009 npm ERR! < ...

Is there a way to display session messages in a CakePHP .ctp file?

There is a button on a view page that requires validation to check the type of user clicking it. We want to restrict certain users from clicking this button and making changes. To achieve this, we are checking the session ID at the time of button click. If ...

If the form is empty, clicking on the Login button will direct you to the page. It is necessary for an error to occur

What should happen when the form is empty and the Login button is pressed? Currently, the page opens without any errors. However, I want to display an error message under such circumstances. How can I modify the function to achieve this? const login = (e ...

Encountering issues with browser tabs and Socket.IO

I'm currently working on a real-time chat using Socket.IO, but I've encountered a major issue. The aim is to allow users to log in, select another connected user, and start chatting... var http = require('http'), fs = require(&ap ...

Tips for organizing the outcome of a seamless web scraping operation with Apify and Puppeteer

Extracting data from a table on the designated URL using Apify and Puppeteer is my current goal: https://en.wikipedia.org/wiki/List_of_hedge_funds The desired outcome should be an array of objects. Each element in the array must represent a <tr> ro ...

A guide on implementing arrow links in D3.js

i am struggling to add an arrow to one end of a link in my code. even though the links are functioning correctly, i can't seem to figure out how to draw arrows successfully. any assistance on how to implement this would be greatly appreciated. thank y ...