Giter VIP home page Giter VIP logo

Comments (9)

connium avatar connium commented on August 16, 2024 1

IMO the current behavior of client.close() is fine (see the link @yaacov referred as [3]).

If there is need for socket.destroy() I would place it in a separate method as @yaacov proposed. Users of this library should not be forced to use internal stuff (client._client should never be used outside the library).

from node-modbus-serial.

yaacov avatar yaacov commented on August 16, 2024

Hi, currently the client.close() [1] method, only calls socket.end() [2]

I do not want to change that behaviour, but we can add a destroy call if necessary, @connium WDYT ?

@sujeethk a workaround that may solve your problem:
calling .destroy() [3] directly on the tcp socket:
client._client.destroy();

[1] https://github.com/yaacov/node-modbus-serial/blob/master/ports/tcpport.js#L97
[2] https://nodejs.org/api/net.html#net_socket_end_data_encoding
[3] https://nodejs.org/api/net.html#net_socket_destroy_exception

from node-modbus-serial.

yaacov avatar yaacov commented on August 16, 2024

Hi all, If the workaround described in #96 (comment) works, I will add a .destory function to the client as @connium suggested.

But we need to know that this was the problem, and that calling client._client.destroy(); fixes it. @sujeethk can you try it, and comment here if this solve/not solve the problem ?

from node-modbus-serial.

yaacov avatar yaacov commented on August 16, 2024

@sujeethk ping ^^

from node-modbus-serial.

sujeethk avatar sujeethk commented on August 16, 2024

Apologies for not getting back earlier. When I log client._client it does not have a destroy method.

And I assume there is a wait timeout for the socket to close before being destroyed which is why the socket doesn't close immediately after calling close.

from node-modbus-serial.

yaacov avatar yaacov commented on August 16, 2024

a. np :-)
b. client._client should be a socket ( it has a destroy method )

  1. can you write here the relevant code you are using ?
  2. where/when socket is still connected,
  3. where/when you see that client._client is not a socket anymore ( does not have a destroy method )

from node-modbus-serial.

yaacov avatar yaacov commented on August 16, 2024

@sujeethk I didn't understand, is this working now ? do we need to close this issue ( it is solve already ) , or we need to fix it , how ?

from node-modbus-serial.

sujeethk avatar sujeethk commented on August 16, 2024

I think we can close this issue since it is working as designed. When we call close on the socket, it flags it for closing but waits until the default timeout to make sure there are no pending transmission from the other client. Once the timeout is done it closes the socket.

from node-modbus-serial.

yaacov avatar yaacov commented on August 16, 2024

Thanks 👍

closing

from node-modbus-serial.

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.