0

I am currently experimenting with websockets and have setup a small server:

from gevent import monkey
monkey.patch_all()

import socketio
from flask import Flask, render_template, request
from flask_socketio import SocketIO

app = Flask(__name__)

sio = SocketIO(app,
               ping_timeout=2, ping_interval=1,
               logger=True, engineio_logger=True)

namespace = '/test'


@sio.on('connect', namespace=namespace)
def on_connect():
    print('Client connected', request.sid)


@sio.on('disconnect', namespace=namespace)
    def on_disconnect():
    print('Client disconnected', request.sid)


if __name__ == '__main__':
    sio.run(app, port=5003)

When I connect to the server (code below) everything works fine, I receive ping/pong debug output in my server console.

var socket = io('//localhost:5003/test');

When I close the browser tab, the connection closes and I received the disconnect event. After the message is printed, I receive the following set of exceptions: gist

This appears similar to this issue from 2015, which was apparently fixed then. I am using

Python 3.6.0 (default, Mar  4 2017, 12:32:34) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin

python-engineio==1.5.2
python-socketio==1.7.4
Flask-SocketIO==2.8.6
gevent==1.2.1
greenlet==0.4.12

Is there something I have done wrong in my setup or is this an issue within socketio?

Birne94
  • 636
  • 8
  • 21
  • I guess this has something to do with the `polling` transport which I unknowingly used. After switching to proper web sockets, the exceptions disappeared. – Birne94 May 18 '17 at 13:26
  • 1
    Right. This stack trace occurs on a disconnection that is forced by the server after noticing the client sort of disappeared, it is not a clean termination where the client closes the connection (note the "client is gone" message before the stack traces). I don't recall these being so noisy, I'll review to make sure I don't output useless exceptions to the log. Even with all this errors, the app continues to work correct? The problem you are asking about is just the noise in the log, I assume? – Miguel Grinberg May 18 '17 at 15:57
  • @Miguel correct, the app kept working properly afterwards. I was just unsure about the error messages, wondering if there was something I did wrong with my setup. – Birne94 May 19 '17 at 08:30

0 Answers0