Modbus Connection to Simulator

Modbus Connection to Simulator

Hi everybody,
I am new to Modbus and Motion Perfect but I am trying to connect the simulator to a server that I would be running on my pc (so far I only want to test the connection to the simulator without any hardware connected).
I set up a minimal server on localhost which does nothing using pyModbusTCP

  1. from pyModbusTCP.server import ModbusServer

  2. server = ModbusServer("", 1234, no_block=True)

  3. try:
  4.     print("Start server...")
  5.     server.start()
  6.     print("Server is online")
  7.     while True:
  8.         pass

  9. except:
  10.     print("Shutdown server ...")
  11.     server.stop()
  12.     print("Server is offline")
And then I try to connect the simulator to the server by running on Motion Perfect this code:
  1. IF MODBUS(0, -1, 127,0,0,1,1234, 20)=TRUE THEN
        PRINT "Modbus Port Open"
        PRINT "Error opening Modbus Port"
But it spits out the "Error opening Modbus Port" error 

However I can connect to the server without any errors if I run on python
  1. client=ModbusClient(host="", port=502)
Does somebody know what I am doing wrong?