0

I am doing a simple client-server application, where the client will send a command through WebSocket connection to the server and the server will respond base on client's command and return a string to the client. I have tested the code to run in local without any problem but when I publish the server to the Azure as app service, when the server sends a string back to the client, the string is truncated to only 3963 characters (original is 5006). Is it the limitation of the Azure app service? This problem only happens on Azure but no problem in local.

const ws = new Websocket({
httpServer: server,
autoAcceptConnections: false
});

const clients = [];

ws.on('request', (req) => {
const connection = req.accept('', req.origin);
clients.push(connection);
console.log('Connected ' + connection.remoteAddress);
connection.on('message', (message) => {
    const dataName = message.type + 'Data';
    const data = message[dataName];
    console.dir(message);
    console.log('Received: ' + data);
    var msg_sent = data;
    clients.forEach((client) => {            
        // Don't send the data back to the original sender
        if (connection == client) { // don't send the message to yourself
            //console.log(msg_sent.toString());
            // Execute every command with non-blocking
            var subMsg = msg_sent.toString().split('\0');

            for (var j = 0; j < subMsg.length; j++) {
                if (subMsg[j] == '')
                    continue;
                Command(subMsg[j], client);
                }
            //Command(msg_sent, sockets[i]);            
        }           
    });
});
connection.on('close', (reasonCode, description) => {
    console.log('Disconnected ' + connection.remoteAddress);
    console.dir({ reasonCode, description });
});

});

user976385
  • 117
  • 1
  • 10

1 Answers1

0

Found the reason, the server send the message in chunks.

user976385
  • 117
  • 1
  • 10