Code Monkey home page Code Monkey logo

Comments (3)

parnic avatar parnic commented on June 13, 2024

Unless I'm reading that wrong, it looks like it's trying to connect to the local host (127.0.0.1) which I assume is not where the pool equipment is located. Is this a local or remote connection? Can you share some code?

from node-screenlogic.

itsxallwater avatar itsxallwater commented on June 13, 2024

A remote. Code isn't too exciting, just slightly adapted from your sample and tucked behind an Express.js server so I can make REST calls from the Vue.js app.

Here's the weird and totally classic tech thing--today, it is working again. Was away from the house for work the last two days so I can't really celebrate anything as the resolution but I'll keep an eye on this. When I reported, I didn't think to bother debugging @ the connect(...) call to validate the IP it was resolving but your point about the peculiarity of localhost was well made. Tossed a break point in there this morning to test and, well yeah, remote IP and a working application. Best guess I've got is perhaps some local network issues that were impacting things when I reported.

🤷

const express = require('express')
const ScreenLogic = require('node-screenlogic')
const cors = require('cors')
const bodyParser = require("body-parser");
const app = express()
const port = 3000
const systemName = "Pentair: ##-##-##"
const password = "##########"

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(cors())

app.get('/', (req, res) => {
    const returnData = {
        systemName: systemName
    }

    var remote = new ScreenLogic.RemoteLogin(systemName);
    remote.on("gatewayFound", function (unit) {
        remote.close()
        if (unit && unit.gatewayFound) {
            getUnitData(unit)
            connect(new ScreenLogic.UnitConnection(unit.port, unit.ipAddr, password))
        } else {
            console.log("no unit found by that name")
        }
    })

    remote.connect()

    // generic connection method used by all above examples
    function connect(client) {
        client
            .on("loggedIn", function () {
                this.getVersion()
            })
            ...
            .on("loginFailed", function () {
                console.log(" unable to login (wrong password?)")
                res.send(returnData)
                client.close()
            })
            .on('error', function(error) {
                console.log("an error occurred")
                console.error(error)
                returnData.error = error
                res.send(returnData)
                client.close()
            })

        client.connect()
    }
})

from node-screenlogic.

parnic avatar parnic commented on June 13, 2024

Glad it's working now. If it turns out that the remote host sometimes returns an invalid IP (perhaps when the local equipment is offline or something?) then that would be good for the library to catch and signal in some well-formed way.

from node-screenlogic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.