Skip to content

Connecting the Modbus #3

@hammadtq

Description

@hammadtq

Hi,

I found an error and struggled with it for a while.

When we acquire a new client via:

var client = new ModbusClient()

The function in modbus.js has:

`ModbusClient = function (timeout, autoreconnect) {

    if (!(this instanceof ModbusClient))
        return new ModbusClient(timeout, autoreconnect);

    // needed for the inheritance
    StateMachine.call(this, 'init');

    var host            = 'localhost',
        port            = 502,
        id              = 0,`

While again, after acquiring the client I am giving host and port:

client.connect(host, port);

After much struggle, I found out that above 'localhost' is creating all the problem. If I change it to the IP address then it works fine. However, I am not sure why library is using an IP there and then also using a different connection function. Can you please have a look?

Great work by the way!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions