You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by udeho <ud...@student.kit.edu> on 2020/05/11 07:55:35 UTC

PlcConnectionException

Dear PLC4X-Community,

I tried to do my first steps with modbus in PLC4X using the modbus simulator referenced in your getting-started guide.
Following your instructions, I executed the following code to establish a connection:

public static void main(String [] args) {

                               String conString = "modbus://localhost";

                               try(PlcConnection plcCon = new
PlcDriverManager().getConnection(conString)){

                                               System.out.println("Hello Modbus");
                               }

                               catch (Exception e) {
                                               e.printStackTrace();
                               }
                }

Unfortunately, I get the following error:

org.apache.plc4x.java.api.exceptions.PlcConnectionException: Connection url doesn't match the format 'modbus:{type}//{port|host}'
at
org.apache.plc4x.java.modbus.ModbusPlcDriver.connect(ModbusPlcDriver.java:69)
at
org.apache.plc4x.java.PlcDriverManager.getConnection(PlcDriverManager.java:72)
at plc4x.playground.main(playground.java:12)

Could you please give me a hint what I'm doing wrong or what is missing?
As far as I can see, I did it the same way you proposed in your virtual modbus section.

Thanks a lot!

Best regards
Tim

Re: PlcConnectionException

Posted by Julian Feinauer <j....@pragmaticminds.de>.
Hi Tim,

sorry fort he issue.
Indeed, the URL of your connection string is wrong (because our docu is really bad).
You should try: modbus:tcp://localhost

Hope that helps!

Julian

Am 11.05.20, 09:55 schrieb "udeho" <ud...@student.kit.edu>:

    Dear PLC4X-Community,

    I tried to do my first steps with modbus in PLC4X using the modbus simulator referenced in your getting-started guide.
    Following your instructions, I executed the following code to establish a connection:

    public static void main(String [] args) {

                                   String conString = "modbus://localhost";

                                   try(PlcConnection plcCon = new
    PlcDriverManager().getConnection(conString)){

                                                   System.out.println("Hello Modbus");
                                   }

                                   catch (Exception e) {
                                                   e.printStackTrace();
                                   }
                    }

    Unfortunately, I get the following error:

    org.apache.plc4x.java.api.exceptions.PlcConnectionException: Connection url doesn't match the format 'modbus:{type}//{port|host}'
    at
    org.apache.plc4x.java.modbus.ModbusPlcDriver.connect(ModbusPlcDriver.java:69)
    at
    org.apache.plc4x.java.PlcDriverManager.getConnection(PlcDriverManager.java:72)
    at plc4x.playground.main(playground.java:12)

    Could you please give me a hint what I'm doing wrong or what is missing?
    As far as I can see, I did it the same way you proposed in your virtual modbus section.

    Thanks a lot!

    Best regards
    Tim