Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Error socket hang up [erledigt]

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Error socket hang up [erledigt]

    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User last edited by A Former User

      Hallo habe hier im Forum das Script gefunden, gestern einmal getestet und wollte es heute benutzen und bekomme immer den Error. Kann mir jemand sagen was ich falsch mache?

      15:38:52.176 info javascript.0 script.js.common.bild: registered 0 subscriptions and 1 schedule
      15:38:54.392 info javascript.0 script.js.common.bild: fetching the data of the snapshot...
      15:38:54.576 error javascript.0 script.js.common.bild: Error: socket hang up```

      function kameraSnapshot() {
       
      const onvif = require('node-onvif');
      const fs = require('fs');
       
      // Create an OnvifDevice object
      let device = new onvif.OnvifDevice({
        xaddr: 'http://192.168.0.136:8999/onvif/device_service',
        user : 'xxx',
        pass : 'xxx'
      });
       
      // Initialize the OnvifDevice object
      device.init().then(() => {
        // Get the data of the snapshot
        console.log('fetching the data of the snapshot...');
        return device.fetchSnapshot();
      }).then((res) => {
        // Save the data to a file
        fs.writeFileSync('/mnt/iobroker/snapshot.jpg', res.body, {encoding: 'binary'});
        console.log('Done!');
        device = null;
        // habe ich noch eingefügt, da ich mir nicht sicher bin ob das device auch wirklich wieder frei gegeben wird insb. wenn ich es in einem CRON - Job laufen lasse
      }).catch((error) => {
        console.error(error);
      })
      } //Ende kameraSnapshot
      schedule('*/5 * * * * *', kameraSnapshot); // alle X Minuten
      setTimeout(kameraSnapshot, 2000);;
      
      1 Reply Last reply Reply Quote 0
      • OliverIO
        OliverIO last edited by

        Etwas an deinen. Verbindungsdaten scheint nicht zu stimmen. Die Verbindung wird auf der Gegenseite nicht angenommen

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User last edited by

          habe es eben nochmal versucht und jetzt geht es auf einmal

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

          Support us

          ioBroker
          Community Adapters
          Donate

          913
          Online

          31.7k
          Users

          79.7k
          Topics

          1.3m
          Posts

          2
          3
          1411
          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