No WebSocket events sent on RPi 3 (Raspbian Buster)

Using the latest official repository version of Mopidy (2.2.3) on an new installation of Raspbian Buster Lite, no events are sent through my WebSockets connection. RPC requests/responses work as expected.

I’m using my own WebSockets client, but the log shows no attempt at sending events, so I would suspect this to be a server issue.

Log extract from an RPC event (Change volume)
DEBUG    2019-09-20 19:38:51,159 [944:HttpServer] mopidy.http.handlers
  Received WebSocket message from [[My IP]]: u'{"jsonrpc":"2.0","id":2,"method":"core.mixer.set_volume","params":[68]}'
DEBUG    2019-09-20 19:38:51,168 [944:SoftwareMixer-1] mopidy.mixer
  Mixer event: volume_changed(volume=68)
DEBUG    2019-09-20 19:38:51,166 [944:HttpServer] mopidy.http.handlers
  Sent WebSocket message to [[My IP]]: '{"jsonrpc": "2.0", "id": 2, "result": true}'
DEBUG    2019-09-20 19:38:51,171 [944:SoftwareMixer-1] mopidy.listener
  Sending volume_changed to MixerListener: {'volume': 68}
DEBUG    2019-09-20 19:38:51,177 [944:Core-10] mopidy.listener
  Sending volume_changed to CoreListener: {'volume': 68}
DEBUG    2019-09-20 19:38:51,181 [944:MpdFrontend-11] mopidy.listener
  Sending mixer to MpdSession: {}
Log extract from an MPD event (Seek track)
DEBUG    2019-09-20 19:39:19,813 [944:Dummy-21] mopidy.audio.actor
  Audio event: position_changed(position=43000L)
DEBUG    2019-09-20 19:39:19,814 [944:Dummy-21] mopidy.listener
  Sending position_changed to AudioListener: {'position': 43000L}
DEBUG    2019-09-20 19:39:19,816 [944:Core-10] mopidy.core.playback
  Triggering seeked event
TRACE    2019-09-20 19:39:19,817 [944:Dummy-20] mopidy_spotify.playback
  Audio requested more data (hint=0); accepting deliveries
DEBUG    2019-09-20 19:39:19,818 [944:Core-10] mopidy.listener
  Sending seeked to CoreListener: {'time_position': 43000}

Search “Broadcast of WebSocket” in logfile gives no hits (based on https://github.com/mopidy/mopidy/blob/master/mopidy/http/handlers.py#L88).

Are you sure you are not closing the websocket connection? I suspect this isn’t a server issue as tools like websocat work just fine. Can you provide the full log and the full mopidy deps?

Just to add, you can also see the websocket events with curl:

curl -i -N -H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Host: localhost:6680" \
-H "Origin: http://localhost:6680" \
-H "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
-H "Sec-WebSocket-Version: 13" \
http://localhost:6680/mopidy/ws

The official JavaScript library shows the same behavior.

Sorry, my account had been put on hold for that second comment. The log extract from my first post also included an “Closed WebSocket connection” message.

I think I need to emphasize that when I write RPC requests/responses in my question, I still send and receive these through WebSockets. It’s only the “event” type messages I do not receive.

I’ve tried to use existing Web Frontends, but none of them receive live updates.

Here is a complete log with the same error occurring: https://pastebin.com/C7aeYh8d

The reason two WebSocket connections are shown is that I tested the official library side-by-side with my own scripts.

This the result of mopidy deps:
Executable: /usr/bin/mopidy
Platform: Linux-4.19.66-v7+-armv7l-with-debian-10.1
Python: CPython 2.7.16 from /usr/lib/python2.7
Mopidy: 2.2.3 from /usr/lib/python2.7/dist-packages
Mopidy-Moped: 0.7.1 from /home/pi/.local/lib/python2.7/site-packages
  setuptools: 40.8.0 from /usr/lib/python2.7/dist-packages
  Mopidy>=1.0.0: 2.2.3 from /usr/lib/python2.7/dist-packages
Mopidy-Spotify: 3.1.0 from /usr/lib/python2.7/dist-packages
  Mopidy>=2.0: 2.2.3 from /usr/lib/python2.7/dist-packages
  Pykka>=1.1: 2.0.0 from /usr/lib/python2.7/dist-packages
  pyspotify>=2.0.5: 2.0.5 from /usr/lib/python2.7/dist-packages
    cffi>=1.0.0: 1.12.2 from /usr/lib/python2.7/dist-packages
  requests>=2.0: 2.21.0 from /usr/lib/python2.7/dist-packages
Mopidy-TuneIn: 0.4.1 from /usr/lib/python2.7/dist-packages
GStreamer: 1.14.4.0 from /usr/lib/python2.7/dist-packages/gi
  Detailed information: 
    Python wrapper: python-gi 3.30.4
    Relevant elements:
      Found:
        uridecodebin
        souphttpsrc
        appsrc
        alsasink
        osssink
        oss4sink
        pulsesink
        id3demux
        id3v2mux
        lamemp3enc
        mpegaudioparse
        mpg123audiodec
        vorbisdec
        vorbisenc
        vorbisparse
        oggdemux
        oggmux
        oggparse
        flacdec
        flacparse
        shout2send
      Not found:
        flump3dec
        mad

That’s odd, why are none of Mopidy’s dependencies shown? The one I wanted to see is the Tornado version as the latest Mopidy release doesn’t support Tornado v5 - one of the issues being broken websocket events. It is fixed in the development version available from github.

If you install Mopidy using pip it will correctly pull in Tornado v4.x, did you install it some other way?

I installed using apt as described in the installation guide.

I also tried to install using pip, but I did it without removing the apt package - I think it reported that Mopidy was already installed.

I can try a clean pip install later today.

Apt should also have pulled in the correct version of Tornado, I hope. Can you see what verison of Tornado you have installed? I’m still puzzled why deps didn’t list everything like normal.

Here’s some info. No Tornado 4.x though.

apt show mopidy
Package: mopidy
Version: 2.2.3-1
Priority: optional
Section: sound
Maintainer: Stein Magnus Jodal <jodal@debian.org>
Installed-Size: 836 kB
Depends: adduser, debconf, gir1.2-gst-plugins-base-1.0, gir1.2-gstreamer-1.0,
gstreamer1.0-plugins-good, gstreamer1.0-plugins-ugly, lsb-base, python-gst-1.0,
python-tornado (>= 2.3), debconf (>= 0.5) | debconf-2.0, python-pkg-resources,
python-pykka, python-requests, python:any (<< 2.8), python:any (>= 2.7~)
Recommends: gstreamer1.0-alsa, gstreamer1.0-pulseaudio, gstreamer1.0-tools
Suggests: mopidy-doc
Homepage: https://www.mopidy.com/
Download-Size: 164 kB
APT-Manual-Installed: yes
APT-Sources: http://apt.mopidy.com buster/main armhf Packages
Description: music server with support for MPD/HTTP clients
 Mopidy is an extensible music server which can play music from local
 files, radio streams, and cloud services such as Spotify and SoundCloud.
 .
 Searches combine results from all music sources, and tracks can be mixed from
 all sources in the play queue. Spotify or SoundCloud playlists are
 also available for use.
apt show python-tornado
Package: python-tornado
Version: 5.1.1-4
Priority: optional
Section: web
Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Installed-Size: 1,800 kB
Depends: ca-certificates, python (<< 2.8), python (>= 2.7~), python-backports-abc, python-concurrent.futures, python-singledispatch, python:any (<< 2.8), python:any (>= 2.7~), libc6 (>= 2.4)
Suggests: python-mysqldb, python-pycurl, python-tornado-doc, python-twisted
Breaks: python-zmq (<< 17.0.0-1~)
Homepage: http://www.tornadoweb.org/
Download-Size: 354 kB
APT-Manual-Installed: no
APT-Sources: http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
Description: scalable, non-blocking web server and tools
 Tornado is a Python web framework and asynchronous networking library,
 originally developed at FriendFeed. By using non-blocking network I/O,
 Tornado can scale to tens of thousands of open connections, making it ideal
 for long polling, WebSockets, and other applications that require a
 long-lived connection to each user.
 .
 This is the Python 2 version of the package.
pip show tornado
Name: tornado
Version: 5.1.1
Summary: Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
Home-page: http://www.tornadoweb.org/
Author: Facebook
Author-email: python-tornado@googlegroups.com
License: http://www.apache.org/licenses/LICENSE-2.0
Location: /usr/lib/python2.7/dist-packages
Requires:
Required-by:

OK, well Tornado 5.x is the problem for sure. I guess the Apt package never got updated with the Tornado version restriction.

So either grab the lastest development version of Mopidy from GitHub (if you are developing a client you’ll want to use that anyway since Mopidy v3.0 will remove many deprecated parts of the API). Or manually pin your Tornado version to 4.x while we sort out the package.

Thanks for the heads up. I had the same issue here and you’re right, Tornado versions was the issue.

I guess the Apt package never got updated with the Tornado version restriction.

Is there a way we can raise a PR to address this as installing the latest development version is not ideal for us and via APT is much easier.

The issue should be fixed. The version problem was specifically restricting Tornado < 5 but the latest release of Mopidy (v2.3.1) supports Tornado 4.4+.

$ apt-cache show mopidy
Package: mopidy
Architecture: all
Version: 2.3.1-1
Priority: optional
Section: sound
Maintainer: Stein Magnus Jodal <jodal@debian.org>
Installed-Size: 817
Depends: adduser, debconf, gir1.2-gst-plugins-base-1.0, gir1.2-gstreamer-1.0, gstreamer1.0-plugins-good, gstreamer1.0-plugins-ugly, lsb-base, python-gst-1.0, python-tornado (>= 4.4), debconf (>= 0.5) | debconf-2.0, python-pkg-resources, python-pykka, python-requests, python:any (<< 2.8), python:any (>= 2.7~)

I would certainly not suggest using the latest development version at this point in time unless you want to help debug Python 3 support.

Thanks, I’ve somehow missed the 2.3.1 release (2019-10-15) I will try this against Buster again later.

1 Like