marvin-mangold / S7-PLC_MySql_MariaDB

MySql and MariaDB communication FB for Siemens PLC S7-1200 and S7-1500
https://marvin-mangold.github.io/S7-PLC_MySql_MariaDB/
MIT License
42 stars 11 forks source link

I cannot connect to the remote database. #6

Closed gadiscz closed 1 month ago

gadiscz commented 3 months ago

When I use xampp in the local network, everything works. When I want to connect to the database (from work at home) via the Internet, I only get error 16#0002, but I connect to the connected DB from the application on the PC.

Port 3306 is therefore open when another application connects.

I don't know what to do next :-(

marvin-mangold commented 3 months ago

You want to connect to the PLC and the database via the Internet.

You say it works with a PC instead of the PLC. But not with the PLC.

When testing, did you set exactly the same IP address and port number in the PLC as on the PC?

If not, it could be due to settings in the router or the firewall on the database PC

gadiscz commented 3 months ago

Yes, in the PLC that I have connected to the PC with a network cable and the PC connected to the Internet via WiFi, I have the same IP of the target server and the same port, as well as the same password and username. I have a public IP on the server and port 3306 is redirected. I have a lot of other programs on the server that I use remotely. The port works when another application is running.

marvin-mangold commented 3 months ago

I think you need to change some settings in the PLC:

grafik

Packets from one network can be forwarded to other networks via gateways. In IP-based networks (e.g. TCP/IP or UDP), packets are forwarded from one subnet to the next subnet via gateways, also known here as routers. Routers store information in a routing table. If a destination IP address is not in its own subnet, the packet is sent to the configured gateway. Routes entered in the routing table determine where the packet is sent.

In STEP 7 the default router is called a router. You activate the use of a router in the inspector window of a CPU in the "IP Protocol" section or from V17 "Internet Protocol Version 4 (IPv4)" with the "Use router" check box. By default, STEP 7 assigns its own IP address to the default router, which must be in the same subnet. The router address set on the PROFINET interface of the IO controller is automatically adopted for its configured IO devices.

support industry siemens