I work on ubuntu 18.04. I set up a virtual environment so that I am sure to work with python3 according to the instructions found here:https://vitux.com/install-python3-on-ubuntu-and-set-up-a-virtual-programming-environment/ Installed pip and eventlet (found that in the docs, resolved earlier issues) Added eventlet code, have no clue what that is about under the hood

I can send something to the server but when this message is broadcast back to all the other clients, the sender of the message does not receive it. When I add a breakpoint the parameter is 'undefined' when I hover over it and when I hover over 'socket' I see 'disconnected: true'. I just don't know what to do about it. I added 'include_self=True' as extra parameter (found in a Miguel Grinberg post). I just don't get what I am doing wrong.


Python Code

import os
import eventlet
eventlet.monkey_patch(all=False, socket=True)

from flask import Flask, render_template, session, request
from flask_socketio import SocketIO, emit, send, join_room, leave_room

app = Flask(__name__)
app.config["SECRET_KEY"] = os.getenv('secret_key')

socketio = SocketIO(app)

def index():
    return render_template('flack.html')

def handle_message(message):
    user = message['username']
    room = message['room']
    emit("join", {"user": user, "room": room}, broadcast=True,         

if __name__ == '__main__':


document.addEventListener('DOMContentLoaded', () => {

  var socket = io.connect('');

  socket.on('connect', function() {
    let submit = document.querySelector("button")
    submit.onclick = function() {
      const user = document.querySelector('input[data-
      const room = document.querySelector('input[data-
      socket.emit('logdata', {'username': user, 'room': room});

    socket.on("join", function(msg) {
      const li = document.createElement('li');
      li.innerHTML = `room: ${msg.room}`;


՝՝՝ HTML

<!DOCTYPE html>
     <script cdn that includes socketio></script>
     <script src="/static/flack.js" type="text/javascript"> </script>
      <input type="text" placeholder="username" data-join="user">
      <input type="text" placeholder="room" data-join="room">
    <ul id="lijst">


1 Answer 1


I removed the form-tags. Now everything is sent to sender and the other clients. I suspect the default method of a form is post, but post is an http-method. Socketio is another protocol, you cannot use http and socketio at the same time. If I'm wrong, I'd love to hear more about it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .