I have a simple node.js server using socket.io that listens for messages. I am sending messages to the server with a Perl script. It seems that the server is receiving messages, but does not recognize the "channel" of the message. How to properly build node.js / socket.io messages to send with a Perl script?
Here is my node.js server:
var express = require('express');
var app = express.createServer();
var io = require('socket.io').listen(app);
app.listen(3000);
io.sockets.on('connection', function (socket) {
console.log("In connection");
socket.on('testevent', function (data) {
console.log("In testevent");
console.log(data);
});
});
Here is the part of my Perl script that sends the message:
$uri = "http://192.168.3.13:3000/socket.io/1/xhr-polling/$clientID";
$message = "5:::{'name':'testevent','args':['hello!']}";
$request = HTTP::Request->new( 'POST', $uri );
$request->content( $message );
print $response = $browser->request( $request )->as_string;
Server log after message received from Perl script:
info - handshake authorized 1598760311220985572
debug - client authorized for
In connection
debug - xhr-polling received data packet 5:::{'name':'testevent','args':['hello!']}
Thus, the node.js server seems to be receiving the message, but does not recognize the "testevent" channel, because I expect the server to write the string "In testevent" if it interprets the message correctly.
Perl, , , ?