Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. node-sonos-http-api

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    node-sonos-http-api

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      skorpil last edited by skorpil

      Da die Verwendung dieser API ja hier beim Sonos Adapter offiziell empfohlen wird: ich habe herausgefunden, dass diese API unter Node.js. 20 nicht mehr sauber funktioniert. Zunächst habe ich das auf den Befehl httpGet geschoben und vermutete hier das Problem. Nach vielen Tests konnte ich das Problem eingrenzen. Hier die Antwort des Entwickler der AP:

      
      I think this is related to this global change in Node 20:
      
      nodejs/node#43522
      
      The Sonos players probably doesn't like keep-alive, and might not properly respond with a Connection: close. The http api will maintain connections and try to send new requests over the old socket and probably confusing the player.
      
      Since this only affects requests that happen within 30-90 seconds (not sure what the default timeout is), this might appear random.
      
      I'll see if I can reproduce it, I haven't run this project under newer Node.js versions in a long time.
      
      

      Hier noch der Link zu meinem anderen Post.

      Hat jemand ähnliche Probleme wie ich?

      ShogunPanda created this issue in nodejs/node

      closed Use Keep-Alive by default in global agents and close idle connections in server #43522

      OliverIO 1 Reply Last reply Reply Quote 0
      • OliverIO
        OliverIO @skorpil last edited by

        @skorpil

        ich glaube die denken da gerade schon nach
        https://github.com/jishi/node-sonos-http-api/issues/907

        virgin09 created this issue in jishi/node-sonos-http-api

        closed Node.js 20 problems #907

        S 1 Reply Last reply Reply Quote 0
        • S
          skorpil @OliverIO last edited by

          @oliverio derjenige, der das Nachdenken angestoßen hat, bin ich😂

          OliverIO 1 Reply Last reply Reply Quote 0
          • OliverIO
            OliverIO @skorpil last edited by OliverIO

            @skorpil ah ok
            gibt es ähnliche bibliotheken auch für andere programmiersprachen? python?
            evtl kann man da mal schauen wie die mit den connctions umgehen.
            weil unterhalb der programmiersprache liegt ja wieder die gleiche schicht an tcpip-stack, mit der alle gleich umgehen müssen.

            S 1 Reply Last reply Reply Quote 0
            • S
              skorpil @OliverIO last edited by

              @oliverio guter Hinweis! Ich habe keine Ahnung. Der Entwickler der APi, Jishi, schrieb bei GitHub, er wolle sich kümmern. Mal sehen…

              Die Frage ist, ob es evtl. hier Profis gibt, die das fixen können. Denn der Code ist ja frei zugänglich!

              1 Reply Last reply Reply Quote 0
              • S
                skorpil last edited by

                leider funktioniert diese schöne API nicht - wie gesagt - unter Node.js 20. Der Entwickler reagiert auch nicht mehr:

                Github Link zur Sonos API

                Ich habe in diesem Issue die Details des Problems beschrieben. Der Entwickler schrieb:

                "I think this is related to this global change in Node 20:

                nodejs/node#43522

                The Sonos players probably doesn't like keep-alive, and might not properly respond with a Connection: close. The http api will maintain connections and try to send new requests over the old socket and probably confusing the player.

                Since this only affects requests that happen within 30-90 seconds (not sure what the default timeout is), this might appear random.

                I'll see if I can reproduce it, I haven't run this project under newer Node.js versions in a long time."

                Meine Frage daher @Bluefox @paul53 oder vielleicht andere Spezialisten:

                Kann jemand von Euch der Code der API so anpassen, dass sie unter node.js 20 wieder funktioniert? Oder kennt jemand eine gute Alternative zu dieser API?

                Danke für Eure Hilfe im voraus

                ShogunPanda created this issue in nodejs/node

                closed Use Keep-Alive by default in global agents and close idle connections in server #43522

                OliverIO 1 Reply Last reply Reply Quote 0
                • OliverIO
                  OliverIO @skorpil last edited by OliverIO

                  @skorpil

                  hier mal was man ausprobieren könnte. leider hab ich kein sonos, kann es daher nicht selbst ausprobieren

                  ausgehend davon, das das die relevante Änderung ist, die der Verursacher ist:

                  const globalAgent = new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 });
                  

                  der globalAgent ist sozusagen der default Agent, der immer dann genommen wird, wenn im request keiner vorgegeben wurde
                  https://nodejs.org/api/http.html#httpglobalagent

                  dann könnte man bei jedem request einen eigenen Agent mitgeben, bei dem dann das keepalive deaktiviert ist?

                  vgl beispiel in der node doku, allerdings mit aktiviertem keepalive
                  https://nodejs.org/api/http.html#new-agentoptions

                  einfach wird es aber nicht, da die sonos bibliothek selbst mit verbogenen und customizten request Objekten arbeitet, soweit ich das auf die schnelle gesehen habe

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    skorpil @OliverIO last edited by

                    @oliverio vielen Dank für den Hinweis. Ich hatte seinerzeit chatGPT befragt. chatGPT hat einen ähnlichen Vorschlag gemacht:

                    „ Adjust Node.js HTTP Agent Settings:

                    Use a custom HTTP agent to override default keep-alive behavior globally for node-sonos-http-api.
                    Example:
                    const http = require('http');

                    const agent = new http.Agent({ keepAlive: false });
                    const options = { agent: agent };“

                    Da ich kein Programmier und ein Javaskript Laie bin, fällt es mir sehr schwer, diese vorgeschlagenen Lösungen in mein Skript zu integrieren. Sollte ich hier mal mein Java Skript posten, damit sich jemand erbarmt, die oben genannte Lösung einzubauen? Oder muss das vielleicht direkt im Programm der API erfolgen?

                    OliverIO 1 Reply Last reply Reply Quote 0
                    • OliverIO
                      OliverIO @skorpil last edited by

                      @skorpil

                      wahrscheinlich in der api. die macht ja die requests.
                      wie gesagt, ist nicht ganz so simple.
                      weiß auch nicht, welche requests da schief gehen.
                      ausserdem scheint die api noch weitere pakete zu verwenden
                      bspw https://github.com/jishi/node-sonos-discovery
                      dort scheint das ganze player discovery und die kommunikation mit einem einzelnen player zu laufen (also play,stop)

                      am besten du gibst mal den hinweis an den maintainer.
                      er kennt ja das problem, weiß aber selbst nicht weiter, wie er schreibt

                      1 Reply Last reply Reply Quote 1
                      • S
                        skorpil last edited by skorpil

                        Der Programmier der API ist tätig geworden und hat sie auf den neuesten Stand gebracht. Jetzt läuft sie auch unter Node.js. 20!

                        Hi, try the latest master (and remember to re-install dependencies with npm install or npm ci, since this is actually fixed in the sonos-discovery package) and see if this solves your problem. I couldn't see the exact error you were seeing, but it's most likely related.
                        

                        Link

                        Hier runterladen!

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        Support us

                        ioBroker
                        Community Adapters
                        Donate
                        FAQ Cloud / IOT
                        HowTo: Node.js-Update
                        HowTo: Backup/Restore
                        Downloads
                        BLOG

                        857
                        Online

                        31.9k
                        Users

                        80.1k
                        Topics

                        1.3m
                        Posts

                        2
                        10
                        608
                        Loading More Posts
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes
                        Reply
                        • Reply as topic
                        Log in to reply
                        Community
                        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                        The ioBroker Community 2014-2023
                        logo