Bugzilla – Bug 16627
invalid JSON from server (2): 'nan' is not a valid JSON-number
Last modified: 2011-10-17 06:03:45 UTC
This one is related to #16404 , but I thought it'd make sense to open different bugs. Here is a log which a user sent over to me. He has the option 'output level fixed to 100%' and the 'mixer volume' then for some reason contained a 'nan' value, not allowed in JSON (it looks like a string on the log - but the actual JSON contains 'nan' without quotes). I cannot reproduce it locally though with my own server As I dump invalid JSON in SqueezePad this leads to lost updates of the playerstate right - I don't know nor tested how SqueezePlay handles this situation. You might also get into problems when updating your Perl library when it gets more strict about allowed values. ---------- [10-10-23 17:32:52.2903] Slim::Web::Cometd::Manager::deliver_events (228) Delivering events to f5420843: [ { channel => "/f5420843/slim/playerstatus/00:04:20:06:0c:45", data => { can_seek => 1, duration => "251.049", "mixer volume" => "nan", mode => "stop", player_connected => 1, player_ip => "10.0.0.13:39445", player_name => "Huiskamer", "playlist mode" => "off", "playlist repeat" => 0, "playlist shuffle" => 0, playlist_cur_index => 1, playlist_loop => [ { # tied Tie::IxHash album => "Blunt Object - Live In Tokyo", arrayRef_artist => ["Bad Plus"], artist => "Bad Plus", artwork_track_id => 79_437, coverart => 1, duration => "251.049", id => 79_439, "playlist index" => 1, title => "And Here We Test Our Power of Observation", }, ], ----------
probably mine to address, as it involves fixed volume which I've been working on recently. though there hasn't been enough information posted about the user's setup, it sounds to me that the user is using SBS 7.6? Please correct if this is in error, as this is important info.
Checked the logs from the user. serverstatus-message returns version 7.5.1 This is the setup of the particular user copied from his mail: "Squeezecenter running on ReadyNas NV+ 4 Squeezeboxes - one SLiMP3 using a wireless bridge - one Squeezebox v1 using built in wireless - one Squeezebox Classic using built in wireless - one Squeezebox Classic using powerline networking When I use SqueezePad, I can see the cover art and "Now Playing" for all three top listed players. When using SqueezePad to control the 4th listed SqueezeBox, I only get the "generic" screen, without cover art or "Now Playing" info." Player 4 was the one with fixed output level. My 7.5.1 server running on a SheevaPlug returns a proper '0' at this place when I use the fixed output level.
from 7.5.1 serverstatus response code: if ($client->hasVolumeControl()) { # undefined for remote streams my $vol = $prefs->client($client)->get('volume'); $vol += 0; $request->addResult("mixer volume", $vol); } this code block is also unchanged in 7.6 SBS I'm puzzled by this bug, because the $vol += 0 is an explicit step to force the data type to be a number. We do this specifically for Lua on the other side, that is very particular about data types (unlike Perl). What you're seeing in that output, 'nan', is an error indicating bad data type (nan = "not a number").
But NaN (like +Infinity and -Infinity) is still a number type (at least in JavaScript, maybe Perl too), so maybe the +0 doesn't help here ? I used this site to help me 'create' a NaN in Perl to fake a JSON with a NaN. This at least isn't handled in the (Perl) JSON Converter, so 'gets through'. http://stackoverflow.com/questions/1185822/how-do-i-create-or-test-for-nan-or-infinity-in-perl I didn't check though what influce a '+0' could have on a NaN, but I guess this doesn't help. I also read that Perl support for NaN might be platform specific, so it could be a special case for ReadyNas.
Just did a small test with a snippet faking a NaN: ----- if ($client->hasVolumeControl()) { # undefined for remote streams my $vol = $prefs->client($client)->get('volume'); $vol=-sin(9**9**9); $vol += 0; $request->addResult("mixer volume", $vol); } ----- I still get the following JSON on the client so the 'trick'/hack with the $vol+=0 doesn't work for NaN that might be introduced earlier on for some reason. ------ { channel = "/15bdeb95/slim/playerstatus/00:04:20:17:1d:38"; data = { "mixer volume" = NaN; mode = stop; "player_connected" = 1; "player_ip" = "192.168.1.10:45967"; "player_name" = Wohnzimmer; "playlist mode" = off; "playlist repeat" = 0; "playlist shuffle" = 0; "playlist_tracks" = 0; power = 1; "seq_no" = 0; signalstrength = 41; }; ext = { priority = ""; }; id = 8; } ------
Andy, now that it's becoming clearer where the break in this JSON, I'm thinking it's not really my area. Reassign as you see fit, but I think this is yours.