6 Replies Latest reply on Jul 13, 2017 9:50 AM by mthakker RSS
    abarletta Newbie

    Socket error occurred connecting [to RaspberryPi]

    Source: Modbus TCP/IP Ethernet

    Event: Channel1.Device1 | Socket error occurred connecting. | Error = 10061, Details = 'No connection could be made because the target machine actively refused it.'.

     

    Has anyone ran into this issue when connecting the Raspberry Pi to KEPServerEX?

     

    As far as I understand, all I have to do to connect is:

    1) format the memory card

    2) write SigmaTile Pixel disk image

    3) put the SD card in Pi

    4) get Pi on the same network as everything else

    5) update Pi from GitHub just to make sure I have the latest code

    6) load the SigmaTile_SenseHat.opf in KEPServerEX

    7) Change Channel1 "ID" to show the Pi's IP Address.

     

    Am I missing something?

      • Re: Socket error occurred connecting [to RaspberryPi]
        varathanran Apprentice

        Can you check whether firewall is blocking??

        Thanks,

        Varathan

        • Re: Socket error occurred connecting [to RaspberryPi]
          stmarchessault Apprentice

          Hello Aldo,

           

          This error reported by the KEPServerEX Modbus TCP driver comes from Winsock. It reveals that the TCP/IP connection attempt was made to a valid IP address and Port, except the destination device (the Raspberry Pi, in this case) actively blocked the attempt to form a socket. Most often, this occurs when the port is already occupied by another TCP session.

           

          What is the port you are trying to connect with? If you did not manually set this in the KEPServerEX Configuration, it will be set to the default Modbus port (502).


          Can you confirm the Raspberry Pi will accept a connection at this port, and there are currently no other applications connecting to the same port?

           

           

          Best regards,

          Steven Marchessault

          Technical Support Engineer | Kepware Technologies

          • Re: Socket error occurred connecting [to RaspberryPi]
            abarletta Newbie

            Steven and Varathan, thank you for the replies.

             

            Actually, it turned out that the SenseHat being physically on the Raspberry Pi was required for it to connect. (I purchased it after RPi)

            I am new to KEPServerEX... I wrongly assumed that the Raspberry Pi being the "brains", it would connect successfully and simply show that the Input/Output devices (SenseHat's sensors) it was expecting to see were not actually present.

            Perhaps it is simply the way this particular project was set up. I have yet to dig into the Python code in the Tile folders and such.

             

            Thank you again for the replies and suggestions,

            Aldo

              • Re: Socket error occurred connecting [to RaspberryPi]
                mthakker Apprentice

                Hey Aldo,

                 

                I wrote the code for the Sigma Tile and you're right - the MODBUS server on the Pi doesn't start up until it acquires data in some way - whether by the default Sense Hat code, or customized for a different set of sensors.  There is almost no error handling or trapping in the code - only a loop if there's no internet connection.

                 

                Thanks,

                 

                Milan

              • Re: Socket error occurred connecting [to RaspberryPi]
                varathanran Apprentice

                Aldo,

                 

                I don't believe the python code is robust enough to handle all error conditions. All our testing was with SenseHat connected since we were getting reading from it.  You should able to add some some debugging statements to Python script and try. Having said that error is misleading but debug statements should shed some light.

                 

                If you don't have SenseHat, you should able to populate some random values in those registers by updating the python script.

                 

                Thanks.

                Varathan

                  • Re: Socket error occurred connecting [to RaspberryPi]
                    stmarchessault Apprentice

                    Hi Aldo,

                     

                    Thanks for the update, glad to hear it's working.


                    It's surprising the addition of the Sense Hat board affected the TCP socket connection, as TCP is very simple (just an IP and a port, then the source/destination three-way handshake). Without that socket connection occurring first, there would be no application-layer transmissions, regardless of the Sense Hat inputs being present or not.

                     

                    Please let us know if the socket error pops up again. I am sure you won't be the last user to encounter this.

                     

                     

                    Best regards,

                    Steven Marchessault

                    Technical Support Engineer | Kepware Technologies