'Socketio showing: polling-xhr.js:203 POST https://tannax.com/socket.io/?EIO=4&transport=polling&t=N_DgMGp&sid=tN5At8vMOxNJ7OWBAAC9 400

I am building a simple chat interface on my web application using Flask Socketio module. The chat interface works very well on my development platform but it doesn't work when I moved the entire flask web application to my domain hosted in a virtual private server. The understated error keeps popping up on console:

polling-xhr.js:203 POST https://tannax.com/socket.io/EIO=4&transport=polling&t=N_DgMGp&sid=tN5At8vMOxNJ7OWBAAC9 400

see my client side code below:

document.addEventListener('DOMContentLoaded', () =>{
        var socket = io.connect('https://' + document.domain + ':' + location.port);

        socket.on('message', data => {
            const p = document.createElement('p');

            const span_username = document.createElement('span');
            const span_timestamp = document.createElement('span')
            const br = document.createElement('br');
            span_username.innerHTML = data.username
            span_timestamp.innerHTML = data.time_stamp;

            p.innerHTML = br.outerHTML + data.msg + br.outerHTML ;
            document.querySelector('#display-message-section').append(p);
            let messageBody = document.querySelector('#display-message-section');
            messageBody.scrollTop = messageBody.scrollHeight;

        });

Please someone should assist me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source