Skip to content
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. English
  3. Scripting / Logic
  4. JavaScript
  5. using iobroker.socket-client in a NodeJs project

NEWS

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    22
    1
    1.1k

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    9.1k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    14
    1
    2.4k

using iobroker.socket-client in a NodeJs project

Geplant Angeheftet Gesperrt Verschoben JavaScript
6 Beiträge 3 Kommentatoren 1.0k Aufrufe 3 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • T Offline
    T Offline
    Taragorm
    schrieb am zuletzt editiert von
    #1

    Hi, I'm in the process of writng a NodeJs project that will talk to IOBroker.

    According to npm:

    @iobroker/socket-client@1.1.14

    when I try to create a connection, I get:

    ReferenceError: window is not defined
        at P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:123:7
        at new Promise (<anonymous>)
        at Connection.waitForSocketLib (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:122:34)
        at new Connection (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:87:10)
    

    As I understand it, this happens because "window" is not defined in NodeJS projects [I am by no means an expert JS programmer, btw]

    So.

    Is this the right library for the job?
    Does it in fact support Node?
    Am I missing some bit of initialisation to create a suitable "window" object under node.

    Hints appreciated.

    AlCalzoneA 1 Antwort Letzte Antwort
    0
    • T Taragorm

      Hi, I'm in the process of writng a NodeJs project that will talk to IOBroker.

      According to npm:

      @iobroker/socket-client@1.1.14

      when I try to create a connection, I get:

      ReferenceError: window is not defined
          at P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:123:7
          at new Promise (<anonymous>)
          at Connection.waitForSocketLib (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:122:34)
          at new Connection (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:87:10)
      

      As I understand it, this happens because "window" is not defined in NodeJS projects [I am by no means an expert JS programmer, btw]

      So.

      Is this the right library for the job?
      Does it in fact support Node?
      Am I missing some bit of initialisation to create a suitable "window" object under node.

      Hints appreciated.

      AlCalzoneA Offline
      AlCalzoneA Offline
      AlCalzone
      Developer
      schrieb am zuletzt editiert von
      #2

      @taragorm That library is meant for the browser.

      Warum `sudo` böse ist: https://forum.iobroker.net/post/17109

      T 1 Antwort Letzte Antwort
      0
      • AlCalzoneA AlCalzone

        @taragorm That library is meant for the browser.

        T Offline
        T Offline
        Taragorm
        schrieb am zuletzt editiert von
        #3

        @alcalzone That was my assumption.

        Is there a NodeJs version?

        I can always use the basic REST interface, but it wouldn't be my first choice here...

        BluefoxB 1 Antwort Letzte Antwort
        0
        • T Taragorm

          @alcalzone That was my assumption.

          Is there a NodeJs version?

          I can always use the basic REST interface, but it wouldn't be my first choice here...

          BluefoxB Offline
          BluefoxB Offline
          Bluefox
          schrieb am zuletzt editiert von
          #4

          @taragorm if you will use normal "ws" library for node.js, it will be possible to communicate with ioBroker. But ioBroker.rest-api is very advanced and supports long polling and web hooks for events.

          T 2 Antworten Letzte Antwort
          0
          • BluefoxB Bluefox

            @taragorm if you will use normal "ws" library for node.js, it will be possible to communicate with ioBroker. But ioBroker.rest-api is very advanced and supports long polling and web hooks for events.

            T Offline
            T Offline
            Taragorm
            schrieb am zuletzt editiert von
            #5

            @bluefox So you suggest the REST interface? - I'll go with that then. The app will likely be running on the same machine as ioBroker, anyhow.

            1 Antwort Letzte Antwort
            0
            • BluefoxB Bluefox

              @taragorm if you will use normal "ws" library for node.js, it will be possible to communicate with ioBroker. But ioBroker.rest-api is very advanced and supports long polling and web hooks for events.

              T Offline
              T Offline
              Taragorm
              schrieb am zuletzt editiert von
              #6

              @bluefox The API seems straightforwards enough; a couple of questions though:

              • How do I unsubscribe? - I didn't see a command for that
              • Can I do a "Bulk" subscribe - i.e. ask for a list of states?
              1 Antwort Letzte Antwort
              0
              Antworten
              • In einem neuen Thema antworten
              Anmelden zum Antworten
              • Älteste zuerst
              • Neuste zuerst
              • Meiste Stimmen


              Support us

              ioBroker
              Community Adapters
              Donate

              891

              Online

              32.5k

              Benutzer

              81.6k

              Themen

              1.3m

              Beiträge
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
              ioBroker Community 2014-2025
              logo
              • Anmelden

              • Du hast noch kein Konto? Registrieren

              • Anmelden oder registrieren, um zu suchen
              • Erster Beitrag
                Letzter Beitrag
              0
              • Home
              • Aktuell
              • Tags
              • Ungelesen 0
              • Kategorien
              • Unreplied
              • Beliebt
              • GitHub
              • Docu
              • Hilfe