Visitar URL original
ConnectionResetError: [Errno 104] Connection reset by peer · Issue #81 · AdvancedClimateSystems/uModbus · GitHub
Skip to content

ConnectionResetError: [Errno 104] Connection reset by peer #81

Open

Description

@unidev10

After tcp.read_coils() function, when I run the command tcp.send_message() I get the error - ConnectionResetError: [Errno 104] Connection reset by peer.
How can this be solved?
Below is my code attached

import socket
from umodbus import conf
from umodbus.client import tcp
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('HOST', PORT))
m2=tcp.read_coils(slave_id=1, starting_address=8193, quantity=1)
response = tcp.send_message(m2, sock)

Activity

  1. OrangeTux commented on Dec 11, 2019

    @OrangeTux
    Collaborator

    Hello @unidev10. You seem to want to connect to HOST and there is no Modbus server running there.

    My guess is that you need to replace HOST with a valid ip or hostname, like:

     sock.connect(('192.168.1.1', PORT))
  2. unidev10 commented on Dec 11, 2019

    @unidev10
    Author

    Hi @OrangeTux, yes I have mentioned the required ip address and the port number in my actual code. It is just for the question, I have replaced the ip address with HOST.

  3. OrangeTux commented on Dec 11, 2019

    @OrangeTux
    Collaborator

    Super! I'll close the issue now. Feel free to reopen if needed.

  4. unidev10 commented on Dec 12, 2019

    @unidev10
    Author

    Hi @OrangeTux, there has been a slight misunderstanding. In my original code, I have written sock.connect(('192.168.0.2', 102)). I am getting the ConnectionResetError for it.

  5. jaapz commented on Dec 12, 2019

    @jaapz
    Member

    Are you sure a modbus server is running on that IP-address? If so, there's probably something in your network filtering out your connection request, like a firewall of some kind.

    The error you get is a more generic error from Python not being able to open a socket. Try to look up ConnectionResetError and under what circumstances Python would raise it.

    I don't think this is a problem with uModbus, as uModbus doesn't do any connection handling, that's all done by the socket module from Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions