simojenki / bonob

sonos SMAPI implementation allowing integrating different music sources with sonos.
GNU General Public License v3.0
221 stars 15 forks source link

SyntaxError: Unexpected token \u0002 in JSON at position 47< #134

Closed mreitschuster closed 1 year ago

mreitschuster commented 1 year ago

Hi,

I am setting up bonob for the first time. I am using Sonos S1 (old Play5 and Play1) and want to connect to my navidrome.

my docker-compose.yml:

version: "3"
services:
  navidrome:
    image: deluan/navidrome:latest
    user: 1000:1000 # should be owner of volumes
    ports:
      - "12345:4533"
    restart: unless-stopped
    environment:
      # Optional: put your config options customization here. Examples:
      ND_SCANSCHEDULE: 1h
      ND_LOGLEVEL: info
      ND_SESSIONTIMEOUT: 24h
      ND_BASEURL: ""
    volumes:
      - "./data:/data"
      - "/pathtoMusik/:/music:ro"
  bonob:
    image: simojenki/bonob:latest
    user: 1000:1000 # should be owner of volumes
    ports:
      - "4534:4534"
    restart: unless-stopped
    environment:
      BNB_PORT: 4534
      # ip address of your machine running bonob
      BNB_URL: http://hostname:4534
      BNB_SECRET: ichangedyou
      BNB_SONOS_AUTO_REGISTER: "true"
      BNB_SONOS_DEVICE_DISCOVERY: "true"
      BNB_SONOS_SERVICE_ID: 246
      # ip address of one of your sonos devices
      BNB_SONOS_SEED_HOST: 192.168.1.235
      BNB_SUBSONIC_URL: http://hostname:12345

navidrome access via browser works on http://hostname:12345 sonos is accessible via http://192.168.1.235:1400/status/VERSION i get to see the new bonob service in sonos app, add it, authenticate. bonob is shown as a new player in the navidrome interface

But when trying to then see the music I get: "unable to browse music" in the Sonos app and on the cli of the docker I see

navidrome-bonob-1      | {"message":"Starting bonob with config {\"port\":4534,\"bonobUrl\":{\"url\":\"http://hostname:4534/\"},\"secret\":\"*******\",\"authTimeout\":\"1h\",\"icons\":{},\"sonos\":{\"serviceName\":\"bonob\",\"discovery\":{\"enabled\":true,\"seedHost\":\"192.168.1.235\"},\"autoRegister\":true,\"sid\":246},\"subsonic\":{\"url\":\"http://hostname:12345\"},\"scrobbleTracks\":true,\"reportNowPlaying\":true}","level":"info","service":"bonob","timestamp":"2023-02-04 15:02:13"}
navidrome-bonob-1      | {"message":"Trying to discover sonos devices using seed 192.168.1.235","level":"info","service":"bonob","timestamp":"2023-02-04 15:02:13"}
navidrome-bonob-1      | {"message":"Listening on 4534 available @ http://hostname:4534/","level":"info","service":"bonob","timestamp":"2023-02-04 15:02:13"}
navidrome-bonob-1      | {"message":"register using sonos device Küche @ 192.168.1.235","level":"info","service":"bonob","timestamp":"2023-02-04 15:02:13"}
navidrome-bonob-1      | {"service":"bonob","form":{"csrfToken":"REMOVED","sid":"246","name":"bonob","uri":"http://hostname:4534/ws/sonos","secureUri":"http://hostname:4534/ws/sonos","pollInterval":"1200","authType":"AppLink","stringsVersion":"23","stringsUri":"http://hostname:4534/sonos/strings.xml","presentationMapVersion":"23","presentationMapUri":"http://hostname:4534/sonos/presentationMap.xml","containerType":"MService","caps":["search","ucPlaylists","extendedMD","logging"]},"level":"info","message":"register with sonos @ http://192.168.1.235:1400/customsd","timestamp":"2023-02-04 15:02:13"}
navidrome-bonob-1      | {"message":"Successfully registered bonob(SID:246) with sonos","level":"info","service":"bonob","timestamp":"2023-02-04 15:02:13"}
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:23 +0000] "GET /sonos/strings.xml HTTP/1.1" 200 31841 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:23 +0000] "GET /sonos/presentationMap.xml HTTP/1.1" 200 8840 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-unselected.svg HTTP/1.1" 200 890 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-unselected.svg HTTP/1.1" 200 890 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star0.svg HTTP/1.1" 200 312 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star1.svg HTTP/1.1" 200 361 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star1.svg HTTP/1.1" 200 361 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-selected.svg HTTP/1.1" 200 518 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-selected.svg HTTP/1.1" 200 518 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star3.svg HTTP/1.1" 200 459 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star2.svg HTTP/1.1" 200 410 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-selected.svg HTTP/1.1" 200 518 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-unselected.svg HTTP/1.1" 200 890 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star2.svg HTTP/1.1" 200 410 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-unselected.svg HTTP/1.1" 200 890 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star3.svg HTTP/1.1" 200 459 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-selected.svg HTTP/1.1" 200 518 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star4.svg HTTP/1.1" 200 508 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star0.svg HTTP/1.1" 200 312 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-unselected.svg HTTP/1.1" 200 890 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star5.svg HTTP/1.1" 200 557 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star4.svg HTTP/1.1" 200 508 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-unselected.svg HTTP/1.1" 200 890 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-selected.svg HTTP/1.1" 200 518 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /star5.svg HTTP/1.1" 200 557 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:24 +0000] "GET /love-selected.svg HTTP/1.1" 200 518 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:38 +0000] "GET /sonos/strings.xml HTTP/1.1" 200 31841 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:127.0.0.1 - - [04/Feb/2023:15:02:42 +0000] "GET /about HTTP/1.1" 200 38 "-" "Wget/1.21"
navidrome-bonob-1      | {"message":{"level":"info","data":"Handling POST on /ws/sonos"},"level":"info","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"debug","data":"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header><credentials xmlns=\"http://www.sonos.com/Services/1.1\"><deviceId>5C-AA-FD-7D-14-B6:2</deviceId><deviceProvider>Sonos</deviceProvider><loginToken><token>REMOVED</token><key>REMOVED</key><householdId>REMOVED</householdId></loginToken></credentials></s:Header><s:Body><getLastUpdate xmlns=\"http://www.sonos.com/Services/1.1\"></getLastUpdate></s:Body></s:Envelope>"},"level":"debug","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"info","data":"Attempting to bind to /ws/sonos"},"level":"info","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"info","data":"Trying SonosSoap from path /about"},"level":"info","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"debug","data":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"  xmlns:tns=\"http://www.sonos.com/Services/1.1\"><soap:Body><getLastUpdateResponse xmlns=\"http://www.sonos.com/Services/1.1\"><getLastUpdateResult><autoRefreshEnabled>true</autoRefreshEnabled><favorites>1675522978</favorites><catalog>1675522978</catalog><pollInterval>60</pollInterval></getLastUpdateResult></getLastUpdateResponse></soap:Body></soap:Envelope>"},"level":"debug","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:58 +0000] "POST /ws/sonos HTTP/1.1" 200 - "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:58 +0000] "GET /sonos/strings.xml HTTP/1.1" 200 31841 "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | {"message":{"level":"info","data":"Handling POST on /ws/sonos"},"level":"info","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"debug","data":"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header><credentials xmlns=\"http://www.sonos.com/Services/1.1\"><loginToken><token>REMOVED</token><key>REMOVED</key><householdId>REMOVED</householdId></loginToken><deviceId>5C-AA-FD-7D-14-B6:2</deviceId><deviceProvider>Sonos</deviceProvider></credentials></s:Header><s:Body><getMetadata xmlns=\"http://www.sonos.com/Services/1.1\"><id>root</id><index>0</index><count>30</count></getMetadata></s:Body></s:Envelope>"},"level":"debug","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"info","data":"Attempting to bind to /ws/sonos"},"level":"info","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"info","data":"Trying SonosSoap from path /about"},"level":"info","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | {"message":{"level":"debug","data":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"  xmlns:tns=\"http://www.sonos.com/Services/1.1\"><soap:Body><soap:Fault><soap:Code><soap:Value>SOAP-ENV:Server</soap:Value><soap:Subcode><soap:value>InternalServerError</soap:value></soap:Subcode></soap:Code><soap:Reason><soap:Text>SyntaxError: Unexpected token \u0002 in JSON at position 47</soap:Text></soap:Reason></soap:Fault></soap:Body></soap:Envelope>"},"level":"debug","service":"bonob","timestamp":"2023-02-04 15:02:58"}
navidrome-bonob-1      | ::ffff:192.168.1.179 - - [04/Feb/2023:15:02:58 +0000] "POST /ws/sonos HTTP/1.1" 500 - "-" "Linux UPnP/1.0 Sonos/57.14-37030 (ACR_:OnePlus:OnePlus9Pro_EEA:LE2123)"
navidrome-bonob-1      | ::ffff:127.0.0.1 - - [04/Feb/2023:15:03:13 +0000] "GET /about HTTP/1.1" 200 38 "-" "Wget/1.21"

I feel the relevant line is SyntaxError: Unexpected token \u0002 in JSON at position 47

Do you have an indication whether that might be a configuration error on my side or a issue?

simojenki commented 1 year ago

That's interesting, never seen that kind of thing happen before.

Perhaps it is related to your music collection itself?

Looks like there is an incorrectly escapted \u0002 char in some json somewhere.

SyntaxError: Unexpected token \u0002 in JSON at position 47

mreitschuster commented 1 year ago

thank you!

Perhaps it is related to your music collection itself? that was it.

I removed a significant chunk of my music library, rescanned in navidrome, stumbled upon a (unrelated?) issue and voila: I can now access my NavidromeMusic Library from Sonos. I will now try to narrow down which file it was.

the unrelated issue: I feel special characters in navidrome login might cause an issue with bonob. When I used an autogenerated PW with many special characters I would often get

navidrome-bonob-1 | {"message":{"level":"debug","data":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://www.sonos.com/Services/1.1\"><soap:Body><soap:Fault><faultcode>Client.LoginUnauthorized</faultcode><faultstring>Failed to authenticate, try Re-Authorising your account in the sonos app</faultstring></soap:Fault></soap:Body></soap:Envelope>"},"level":"debug","service":"bonob","timestamp":"2023-02-05 09:43:06"}

And in Sonos App it would show something like "your trial with bonob is over". As soon as i changed PW to something simple with only letters and numbers I stopped having that issue.

simojenki commented 1 year ago

That's interesting. What happens if you include the character '<', '>', '"' or '&' in your password?

mreitschuster commented 1 year ago

I have now finished readding all music to my library and could not reproduce the initial issue SyntaxError: Unexpected token \u0002 in JSON at position 47

I think the issue with the password is triggered by the € character. A pw with the 4 characters you mentioned works, but as soon as i add € it fails. The exact message in Sonos is Unable to browse music - your bonob trial has expired. and the log shows:

navidrome-bonob-1 | {"message":{"level":"debug","data":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://www.sonos.com/Services/1.1\"><soap:Body><soap:Fault><faultcode>Client.LoginUnauthorized</faultcode><faultstring>Failed to authenticate, try Re-Authorising your account in the sonos app</faultstring></soap:Fault></soap:Body></soap:Envelope>"},"level":"debug","service":"bonob","timestamp":"2023-02-05 13:19:16"}

I have a hunch now this might actually be connected to the "unable to browse music/unexpected token in json" issue. Because what happened initially was I get the "trial expired" message, and a while later it would then change into the "unable to browse music" without any config or library change. When I encountered the "unable to browse" error I still had a € in the password.

I will now leave my config as is (with € pw) for an hour or two to see if that really is what happens.

mreitschuster commented 1 year ago

I was not able to reproduce the SyntaxError: Unexpected token \u0002 in JSON at position 47. Everything is working fine for me now. What I did since it popped up was:

the second is reliably reproducing the Unable to browse music - your bonob trial has expired issue when I change my pw.

@simojenki Thank you very much for your help and this great tool!