No connection to arduino when php site is on server

Hello guys,

at first i have to apologize for my bad english, as i am not a native speaker.

I've got a problem concerning controlling my Arduino via PHP over the Internet.

My Arduino is set up in the home network, i've set up port forwarding and a dynamic dns for my router. All of it works well.
To control my Arduino i've created a php site which uses the fwrite function pointing at my dynamic dns domain and the forwarded port.
As long as i set up my PHP site on my own pc via apache server it works, but if i run it from a real server (i use the hoster bplaced.net, which is definitely able to handle php), its not working anymore.
I checked the php site over and over again and in my opinion it's set up right.
Furthermore i can access my arduino over the internet. If i type in my globalip:targetport in my browser (I've tried it via my mobile phone without wifi connection to check if it works via internet) the arduino receives a http request. So the "way" is free and no firewall blocks the connection.

Anyhow, if i set up my own apache server and access it via my dynamic dns domain it works perfectly but as soon as i run the site on a real server provided by a hoster there is no connection to the arduino. I've checked the ip's a thousand times and i am using the right target : dynamic dns domain as ip and the forwarded port. So im absolutely sure that i dont use the ip of the arduino provided by the router.

Does anyone have an idea where the problem might be?
Im thankful for every answer :slight_smile:

I presume bplaced.net is a virtual server. Are you sending a "Host:" parameter with your request?

Im pretty new to php programming,
so the "request" i send to the arduino is following:

$arduino_ip="tcp://xxxx.org";
$arduino_port="4xxx";

$bright = $_POST["bright"];
$switch = $_POST["switch"];
$color = $_POST["color"];
$fade = $_POST["fade"];

$command = "Switch:$switch&Color:$color&Bright:$bright&Fade:$fade&";

function arduino_send($ip,$port,$command) {
$res = fsockopen($ip,$port);
if($res) {
fwrite($res,$command);
}

}
arduino_send($arduino_ip, $arduino_port, $command);

That is the server end. What are you sending with the request from the Arduino client? Post your Arduino code.

Thanks for your reply.
The arduino actually doesnt send anything... The Code just Sets up an WiFi and tcp connection and is listenting to the forwarded port. The Code just processes the Data it receives from the php site.

Then you probably have a problem with your router. Is your Arduino behind a router? Does the Arduino have a private IP address?

Yes its behind a Router and yes it Has a private IP adress.... But i can reach it through Internet as i stated in my First Post.... So im pretty sure the Problem is related to the Server or the php code